{"id":8323,"date":"2020-06-30T20:16:04","date_gmt":"2020-06-30T20:16:04","guid":{"rendered":"http:\/\/putridparrot.com\/blog\/?p=8323"},"modified":"2020-06-30T20:19:23","modified_gmt":"2020-06-30T20:19:23","slug":"github-net-core-action","status":"publish","type":"post","link":"https:\/\/putridparrot.com\/blog\/github-net-core-action\/","title":{"rendered":"Getting started with GitHub and the .NET Core Action"},"content":{"rendered":"<p>GitHub actions allows us to add workflows to our projects. <\/p>\n<p>In the previous three posts we looked at using Appveyor, Circleci and Travis CI to create our CI\/CD pipelines, now let&#8217;s look at using GitHub Actions. <\/p>\n<ul>\n<li>From your GitHub project, select the Actions tab<\/li>\n<li>GitHub kindly lists a suggested workflow, so as my project is in C# it suggests a .NET Core build action, select <em>Set up this workflow<\/em> if it suits your needs (it does for this example)<\/li>\n<li>You&#8217;ll now get to edit the Actions yml configuration, I&#8217;ll accept it by clicking <em>Start commit<\/em> and this will add the dotnet-core.yml to .github\/workflows<\/em>. Just click commit to add it to your repository.<\/li>\n<li>From the Actions | .NET Core workflow, press the Create status badge, then Copy status badge Markdown and place this markdown into your README.md<\/li>\n<\/ul>\n<p><em>Note: If you&#8217;re using the .NET Core workflow and using multi targets (i.e. &lt;TargetFrameworks&gt;netcoreapp3.1;net472&lt;\/TargetFrameworks&gt; then you may find the build failing because the .NET 4.7.2 frameworks is not installed.<\/em><\/p>\n<p>The process described above, demonstrated that we have a YML based DSL for creating our workflow, checkout <a href=\"https:\/\/help.github.com\/en\/actions\/reference\/workflow-syntax-for-github-actions\" rel=\"noopener noreferrer\" target=\"_blank\">Workflow syntax for GitHub Actions<\/a>.<\/p>\n<p>Let&#8217;s take a look at a workflow file for one of my projects &#8211; in this case .NET core was not suitable, instead I wanted .NET Framework<\/p>\n<pre class=\"brush: csharp; title: ; notranslate\" title=\"\">\r\nname: .NET Core\r\n\r\non:\r\n  push:\r\n    branches: &#x5B; master ]\r\n  pull_request:\r\n    branches: &#x5B; master ]\r\n\r\njobs:\r\n  build:\r\n\r\n    runs-on: windows-latest\r\n\r\n    steps:\r\n    - uses: actions\/checkout@v2\r\n    - name: Setup MSBuild Path\r\n      uses: warrenbuckley\/Setup-MSBuild@v1\r\n      \r\n    - name: Setup NuGet\r\n      uses: NuGet\/setup-nuget@v1.0.2\r\n     \r\n    - name: Restore NuGet Packages\r\n      run: nuget restore MyApplication.sln\r\n \r\n    - name: Build\r\n      run: msbuild MyApplication.sln \/p:Configuration=Release \/p:DeployOnBuild=true\r\n<\/pre>\n<p>The <em>name<\/em> is what you&#8217;ll see in your list of GitHub actions (via the GitHub project&#8217;s Actions tab\/button, this workflow monitors pushes and pull requests on master and then has a list of jobs to undertake once this workflow is triggered.<\/p>\n<p>We&#8217;re going to run this workflow on Windows as the project is a .NET framework application. The steps of the workflow specify the &#8220;parts&#8221; required to build and test the project, so require the checkout action and Setup-MSBuild, setup-nuget libraries. Then we run the nuget restore to get all nuget package then build the application.<\/p>\n<p><em>Note: I&#8217;ve not include tests as yet on this workflow, so I&#8217;ll leave that to the reader.<\/em><\/p>\n<p>As usual we&#8217;ll want to create a badge, in the Actions tab in GitHub, select the workflow and on the right of the screen is a button <em>Create status badge<\/em>. Click this then press the <em>Copy status badge Markdown<\/em> button and this will place the Markdown into your clipboard. Here&#8217;s an example of mine<\/p>\n<pre class=\"brush: csharp; title: ; notranslate\" title=\"\">\r\n!&#x5B;.NET Core](https:\/\/github.com\/putridparrot\/MyApplication\/workflows\/.NET%20Core\/badge.svg)\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>GitHub actions allows us to add workflows to our projects. In the previous three posts we looked at using Appveyor, Circleci and Travis CI to create our CI\/CD pipelines, now let&#8217;s look at using GitHub Actions. From your GitHub project, select the Actions tab GitHub kindly lists a suggested workflow, so as my project is [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[301,297,304],"tags":[],"class_list":["post-8323","post","type-post","status-publish","format-standard","hentry","category-ci-cd","category-github","category-github-actions"],"jetpack_sharing_enabled":true,"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/putridparrot.com\/blog\/wp-json\/wp\/v2\/posts\/8323","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/putridparrot.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/putridparrot.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/putridparrot.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/putridparrot.com\/blog\/wp-json\/wp\/v2\/comments?post=8323"}],"version-history":[{"count":5,"href":"https:\/\/putridparrot.com\/blog\/wp-json\/wp\/v2\/posts\/8323\/revisions"}],"predecessor-version":[{"id":8335,"href":"https:\/\/putridparrot.com\/blog\/wp-json\/wp\/v2\/posts\/8323\/revisions\/8335"}],"wp:attachment":[{"href":"https:\/\/putridparrot.com\/blog\/wp-json\/wp\/v2\/media?parent=8323"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/putridparrot.com\/blog\/wp-json\/wp\/v2\/categories?post=8323"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/putridparrot.com\/blog\/wp-json\/wp\/v2\/tags?post=8323"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}