GitHub actions… CI in 5 clicks

category: [ Uncategorized ] tags: [ GitHub ] [ GitHub Actions ]
created: 19 Aug 2019 @ 20:20 modified: 19 Aug 2019 @ 20:21


If you don’t know yet what GitHub actions are you can read about it on the GitHub Actions feature on GitHub. In short on the 8th of August GitHub announced an update to their actions which you can read about in this blog post. it’s a very easy way to automate anything from any event in GitHub.

Let’s get started

I started this example with a new asp.net core 3 project.

image

The project itself is not relevant for anything more than having a piece of code, in this case asp.net core 3 code that we can see how easy it is to configure the new actions with. I’ve pushed that code to GitHub to a repo called GitHubActionsSample

image

After the commit and push you can see that the code is on GitHub as you’d expect and we ready to start the actual 5 clicks Open-mouthed smile.

Click 1

For our first click we are going to click on the actions tab

image

Nothing to complicated here, we are shown a list of all our defined workflows but we have non yet so let’s continue

Click 2

You’ll see a list of samples on the page as well as options to just start fresh but what we are going to do is scroll down a little and click on the ‘more’ option

image

This will expand to show us a lot of workflows that we could perform for various frameworks and tools

Click 3

In the list scroll until you come across ASP.NET Core and then click Set up this workflow

image

That will show you a YAML file that is mostly ready for us to just run. The file should be easy enough to just read through and understand what is going on in it, let’s parse through it quickly

  1. The name of the workflow is called ASP.NET Core CI, this we can change if we want to something more meaningful. This will help us identify the workflow amongst the many others that we could end up creating
  2. This workflow is going to trigger on any push event to our repo
  3. Our workflow is going to run on ubuntu compute
  4. As part of our steps we are going to reuse an existing action called checkout, using it’s v1 version
  5. We are also using an existing action that does environment setup for dotnet
  6. and with that setup we are asking for the SDK for version 2.2.108 to be added to the environment and then
  7. lastly we are running the command dotnet build –configuration Release

image

All this is great but we are going to just adjust the version mentioned at point 6 to target asp.net core 3 preview 8 release because that is (at least in this example of mine) what our code requires.

image

I’ve updated the YAML file to reflect sdk version 3.0.100-preview8-013656

Click 4

As far as configuration is concerned we are done, click Start commit

image

Almost there Smile

Click 5

Now all that is left is to type a comment and then click Commit new file

image

You are all set!

Status of your workflows

You’ll notice now that if you go over to the Actions tab that your action will show up as you can see below and you’d be able to click on the ‘run’ for your branch and see more details for it

image

That will bring up the summary for your workflow run and if it’s still busy you will see the live stream of the logs to the console in your browser

image

and now as well if you check your commits they have an indicator on them that shows a status that in this case shows success

image

and when clicked on shows you a little more information, clicking on Details takes you to the full summary log view 2 images above.

image

As you can see GitHub actions are extremely easy to setup. The source for the actions lives with your code so you can easily evolve them as your code evolves. Lastly if your scroll through the list of sample workflows you can see that there are many different workflows provided out of the box to get you setup fast but more importantly you can build your own actions, a post for that will come soon Smile.

Enjoy!

ABOUT ME

Gordon Beeming works at Nologo Studios in the sunny city of Durban, South Africa. He is the Lead for the Data and Services Team and has a strong focus on Developer Efficiencies and R&D. When he's not hacking away at a keyboard in Visual Studio he'll generally be relaxing with his family or hitting the black top getting in some mileage. He is a Visual Studio ALM Ranger and Visual Studio ALM MVP.

Follow me on Strava

TOOLS

I plan on writing a bunch of online tools and sharing the code for how I made those tools. If you have any feedback you can ping me on Twitter (@GordonBeeming) or mail me [email protected].