Github Actions
Github action is a tool that lets you automate your software development workflows. We can write individual tasks, called actions
, and combine them to create a custom workflow
.
Workflows
Worflows are custom automated processes that you can setup in your repository to build, test, package, release, or deploy any code project on Github.
Suppose, we have a github repository and on this repository, certain events such as push
, pull request
, Issue request
etc can occur at any time. Now, we can perform some workflow when these events happens. Now, as discussed, workflow is a bunch of actions that we run such as each action performs certain tasks. For example:
- A workflow can be testing and deploying code when someone pushes to master.
- Run some tests when someone opens a pull request.
- Send a slack message when an issue is created and so on.
We can run a workflow on a regular schedule such as everyday at 12 noon or when some external events occur.
A workflow occurs on a virtual machine on some github server. A workflow can contain one or more jobs and each job runs on its own virtual machine. Assume that an event happens on a repository and we have configured some tests to run when that event happens. So, a virtual machine is booted up for each job that we have in our workflow. This virtual machine can be a linux, windows, macOS or docker containers. For each job, we perform some bunch of steps and each step should perform an action
such as deploying a code to a service like heroku.
In summary, a workflow contains one or more jobs where each job performs some steps, called actions.
Runner
A runner can be any machine with the github actions runner application installed. A runner is responsible for running jobs whenever an event happens and displays back the results. We can either have github hosted runner or self-hosted runner. A github hosted runner is maintained by github and we cannot customize the hardware configuration while a self-hosted runner is a machine which we manage and maintain ourselves with the runner application installed and we have more control of hardware and operating system.
Within github-hosted runners, we have some pre-installed software tools installed within our virtual environments. Some of these tools are curl, git, npm, yarn and pip.
Important while creating workflows on github.
git init
git remote add origin git@github.com:smazcw3/github-actions-test.git
git remote -v
git add -A
git commit -m "first workflow"
git push --set-upstream origin master