Github Actions Basics
\144\150\162\165\166(dhruv)
Posted on November 18, 2023
Github Actions are used to automate project management tasks by using workflows.
- Each Workflow contains a series of tasks, which are implemented or run automatically everytime when the workflow runs.
Github Action is a CI/CD(Continuous Integration and Continuous Delivery) platform that allows you to automate your build, test and deployment pipelines
The Components of Github Actions:
1.Workflow:
- Workflow is a configurable automated process that will run one or more jobs,
- defined by a YAML file/Syntax,
- and it's placed inside
.github/workflows
path
2.Events:
- it is Something that triggers Workflows
3.Jobs:
- Job is a set of steps in a workflow, each step is either a
Shell script
or anaction
- Steps are executed in order, and are dependent on each other.
- Data Sharing mechanism is integrated into the steps, since they are dependent on each other
4.Actions:
- Custom application for the Github Actions platform that performs a complex but frequently repeated tasks
5.Runners:
- is a server that runs your workflow when they are triggered.
Let us Understand the Workflow file(YAML):
name: learn-github-actions
- it will appear in the 'Actions' tab of the Github Repository
- it is an optional step
run-name: ${{github.actor}} is learning Github actions
- it specifies the name of workflow run, that will appear in the list of workflow runs on 'Actions' Tab
on: [push]
- specifies the trigger for the Workflow
jobs:
- Groups all the jobs that run in the learn-github-action workflow
check-bats-version:
- Defines a job named
check-bats-version
. The child keys will define properties of the job.
runs-on: ubuntu-latest
- configures the job to run on the latest version of the Ubuntu Linux runner(Fresh virtual machine hosted by Github)
steps:
- groups together all the steps that runs in this job. Each item nested under this section is a separate
action
or ashell script
.
-uses: actions/checkout@v4
- The
uses
keyword specifies that this step will runv4
of theactions/checkout
action. - This actions checks out your repository onto the runner, allowing you to run scripts or other actions against your code.
-uses: actions/setup-node@v3
with:
node-version: '14'
- This step uses the
actions/setup-node@v3
action to install the specified version of the Node that will be used for the project - This puts both the
node
&npm
commands in your Path
-run: npm install -g bats
- The run keyword tells the job to execute a command on the Runner.
- In this case, you're using
npm
to installbats
software testing package.
-run:bats-v
- Finally you'll run the
bats
command with a parameter that outputs the software version.
Thanks for reading the tutorial!
If you have any feedback, then you can DM me on Twitter or Linkedin.
💖 💪 🙅 🚩
\144\150\162\165\166(dhruv)
Posted on November 18, 2023
Join Our Newsletter. No Spam, Only the good stuff.
Sign up to receive the latest update from our blog.