
Introduction to GitHub Actions and how to use them
19 July, 2022
7
7
1
Contributors
Introduction
What are GitHub Actions ?
Continues Integration (CI)
•
Continues Delivery (CD)
•
Continues delivery is an extension of continues integration since it automatically deploys all the changes to testing (or) production enviroment after the build stage is completed. This means that on top of automated testing process you have an automated release process with which you can deploy your application at just the click of a button.
•
With continues delivery you can release daily, weekly or monthly whatever suits your business requirements. It is recommended that you should deploy your application to production as early as possible and afterwards release small batches so that it will be more easy to troubleshoot in case of a problem.
Components of GitHub Actions
•
•
•
•
•
Workflows
.github/workflows
directory inside a GitHub repository. A GitHub repository can have multiple workflows each of which can perform a different set of tasks, You can have one workflow which builds and tests your pull request and another workflow which adds label to every new issue created. For more information related workflows visit hereEvents
Jobs
Actions
Runners
Creating an example workflow
.github/workflows/
directory.
GitHub-Actions-Demo-Workflow
. After creating the repository successfully clone it your device git clone <repositoy - name>
cd <folder - name>
1.
create a new directory name .github
in your repository using terminal mkdir .github
2.
Inside the .github
directory create a new directory named workflows
and inside the workflows directory create actions.yaml
file and paste this code inside it,
Understanding the workflow
name: learn-github-actions
on : [push]
event, The on tag is used to specify certain event to the repository whether it can be a pushing a normal commit or merging a pull requestjobs
tag which will group together all the jobs that will run in the workflow learn-github-actions
check-bats-version
this is the name of the job and the child keys will define the properties for this jobruns-on: ubuntu-latest
the runs-on tag will specify the workflow to run on a specific server. This means that the job will execute on a fresh hosted virtual machine hosted by githubsteps
this tag groups together all the steps that will run in the check-bats-version
job. Each item is nested under this step and is a different action or a shell scriptuses: actions/checkout@v3
This step will specify to run the v3
of actions/checkout@v3
action. This step will checkout your repository on the runner and allow you to run scripts and actions against your code such as build and test tools.
uses: actions/setup-node@v3
with:
node-version: '14'
This action will install the node
with version 14 on your repository.run: npm install -g bats
The run keyword will tell the job to execute a command on the runner. In this command we are installing the bats software testing package globally on our repositoryrun: bats -v
after the bats package is installed, we will run the bats command to check the version of our softwareViewing the activity on GitHub for a workflow run




check-bats-version
executed
Conclusion
github
devops
developer-tools
github-actions