GitHub Actions?
The Long Story
TL;DR
GitHub Actions is a toolkit that aids in the customization of a software development life cycle. In some cases, it will be rather simple to think of GitHub Actions as a continuous integration/continuous delivery(deployment) (CI/CD) service equivalent hosted by GitHub itself. A short example of GitHub Actions's application would be automating email notifications whenever a merge/pull/whatever request is made.
Jargons
Runners
Runners are preferably Docker containers of which GitHub Actions run on. The context of this article would primarily be restricted to GitHub-hosted runners; however, please be aware that self-hosted runners are always an option and might come in handy when highly-customized workflow is needed.
Events
Events are workflow triggers. Events can be tweaked to listen to a specific activity, say, specified branch merges.
Jobs
Each defined job will run on a separate GitHub-hosted runner. Jobs can run parallelly, sequentially, and/or even conditionally.
Steps
Steps are building blocks of a job and run sequentially without any specifications. Steps that are defined in the same job share the same runner. They can be called to execute commands or use actions that have been created by one or another.
A "Hello World" for GitHub Action (Explanations will come)
-
Create a directory named
.github/workflows/
on the same level as your.git
folder. -
Create a YAML(Your Yaml Guide) configuration file
./github/workflows/{YOUR_WORKFLOW_NAME}.yml
that resembles the following. -
Push it along with your repository.
-
GitHub would automatically scan all
.yml
and.yaml
files contained within the previously mentioned directory and instantiate runners to hold the workflows configured by the YAML files.
But What Exactly Is Going on?
-
The above configuration file defines a task named 'test' that will be triggered whenever a push occurs on the branch master. When the task is triggered, GitHub Actions instantiates a job-running host on its server running the latest version of ubuntu. This host executes two steps, a pre-made action that sets up the python environment for that host and a self-defined
hello world
action that runs solely on command line.
- Go to
Actions
to see the details.
- Go to
test
to see more details
- You now can see the statuses of your jobs and the steps within it. This is where you should be looking up primarily for troubleshooting.
Tweaking to Your Heart's Extent
- GitHub Actions can do many more.
- You can configure a workflow that triggers on push, pull requests, create, delete, and the list goes on. Check this for more details on event listeners.
- You can run your host on Ubuntu, Windows, or even MacOS. Note that the pricing may differ, especially for MacOS, which usually is ten times the pricing of setting up a Linux environment. Pricing Details
- You can use actions made by someone else. They're all in the GitHub Actions Market, here. Their usage might differ, so it's recommended that you read their documentations beforehand.