I needed to understand the fundamentals to setup a GitHub Actions workflow, the links in the references explain the costs, Linux builds are the clear favorite.
The workflow structure is: workflow
-> jobs
-> steps
-> run
Simple version check workflow
This will build out a workflow that just checks the version of your developer sdk on the build agent.
- Create and clone a new repository, mine was https://github.com/carlpaton/github-actions-workflow-demo
- Create a workflow as
.github/workflows/build.yml
, where build.yml can be named anything related to your workflow
1 | on: push ~ the trigger event is a push to this repository |
These run steps are shell commands but can also be actions (see Actions below)
- Commit and push
- Inspect the workflow outcome for the commit by clicking the actions tab
- Here I can see the jobs, following the demo I called it
first-job
- Clicking
first-job
I can see the steps
- On closer inspection I can see the machine it ran on was
Image: windows-2022
and the results of my version steps
This can then be adapted to perform more complex workflows simliar to the actions below.
Actions
“Actions are custom applications that run complex but repetitive tasks. For example, we can have a docker action which builds a docker image and runs a container that executes certain commands.”
Example Restore, Build and Test
for an example .Net project
1 | on: push |
This will restore, build and test the .Net project
The actions I used here are
Triggers
There are many, see https://docs.github.com/en/actions/writing-workflows/choosing-when-your-workflow-runs/events-that-trigger-workflows
These are common ones I’ve used so far:
- pull_request - Runs your workflow when activity on a pull request in the workflow’s repository occurs
- push - Runs your workflow when you push a commit or tag, or when you create a repository from a template
- workflow_dispatch - To enable a workflow to be triggered manually
References
- Build your first GitHub Actions workflow
- https://github.com/features/actions
- https://docs.github.com/en/actions/about-github-actions/understanding-github-actions
- https://docs.github.com/en/actions/writing-workflows/workflow-syntax-for-github-actions
- https://docs.github.com/en/billing/managing-billing-for-github-actions/about-billing-for-github-actions