GitHub Actions| Learn the components of GitHub Actions

GitHub Actions| Learn the components of GitHub Actions
Techiio-author
Written by Debarghya DasJanuary 8, 2022
11 min read
Github
0 VIEWS 0 LIKES 0 DISLIKES SHARE
0 LIKES 0 DISLIKES 0 VIEWS SHARE
Techiio-author
Debarghya Das

Junior Front-End Developer

In this blog post, we will know about GitHub Actions Components and what is it...

About GitHub

GitHub, Inc. is a provider of Internet hosting for software development and version control using Git. It offers the distributed version control and source code management (SCM) functionality of Git, plus its own features. It provides access control and several collaboration features such as bug tracking, feature requests, task management, continuous integration, and wikis for every project. Headquartered in California, it has been a subsidiary of Microsoft since 2018.

blogpost

Introduction to GitHub Actions

GitHub Actions actives engineer's to active Agile program development method to deliver results to the users in the shortest possible time without compromising everything on software quality, standards, processes, and security aspects. Actions empower developers to automate the software development lifecycle and allows customization of the workflow wherever needed while it gets executed.

Actions facilitate Continuous Integration and Continuous delivery of software from GitHub repository which ensures code under development is moved to production within a short time cycle so that users get benefitted most by improved accuracy in the application delivery, reduction in the development cost, and improvement in the revenue generation for the organization.

blogpost

Components of GitHub Actions

Several components in Actions helps in configuring a development life cycle including testing of software till its deployment. Some of the major components are:

Events

Workflows can be triggered or configured to run whenever an event occurs. An event is a specified activity that can happen as part of Actions or scheduled at a particular time within GitHub or happen outside of GitHub.

Type of events that triggers Workflow execution

  1. Upon the occurrence of a single event. Example – Whenever code is moved into any part of the GitHub repository
  2. Upon the occurrence of Multiple events e.g. Whenever one of the listed events like Code push or Code Pull occurs.
  3. Upon the occurrence of an event with a specific activity type. e.g. Workflow can be triggered whenever code is pushed in the main branch (Activity type) or code is released under created category (Activity type).
  4. At a particular time as a scheduled event. g. Cronjob can be run in the backend which will wake up at a scheduled time, trigger workflow, set up the next wake up time, and go to sleep till that time.
  5. Manually triggered whenever required

Workflow

Workflow is a set of procedures that are logically connected and made available in the GitHub repository. As described above these workflows are triggered by various events. Workflow is packaged as YAML files and users can create, test and deploy these workflows as a project.

A typical workflow contains various Jobs which have several steps and each step has an action to get the results. Some of the Workflow may be simple and some may be complex that stores sensitive information. Such data like certificates/passwords will use stored as secrets in the workflow as an environment variable and used as parameter during the retrieval of information.

GitHub simplifies the creation of workflows by providing them a master template workflow for users to customize and create their workflow as per the requirement.

Jobs

Jobs that run as part of a workflow consists of a set of several steps. These steps are getting executed in the same runner to share data among steps. Normally the jobs in the workflow are executed as parallel operations unless there are dependencies between jobs. There could be a dependent job whose execution can start only upon completion of another job. In that case, these two jobs cannot run in a parallel model and they will have to go in a serial mode and it has to be configured in actions as serial jobs.

Steps

Steps are part of a Job in GitHub Actions. These steps execute commands, tasks setup, actions defined in the repository. A step may contain an action or a shell command. But action is run as a step in a repository and it is executed as a process in the runner environment with needed resources like file system and workspace. Since each step is considered as its process GitHub does not preserve the changes to environment variables.

Actions

Action can be a discrete task or custom codes to interact with repository objects. Actions can be combined into steps and in turn into jobs as part of a workflow. Interfaces available within GitHub or third-party interfaces (API) can be used as part of custom code in action. Actions can run either on machines or through docker containers depending on the need.

Runner

It’s a server that hosts the application in GitHub Actions that performs assigned tasks. Users can use the runners provided by GitHub or they can have their runners. Runners execute a job at a time and report back the results to GitHub.

Sample Workflow

To create a sample workflow all a user need is just a GitHub repository. A directory .github/workflows should be created if it is not already available.

Creation of a sample workflow file

A file github-actions-sample .yml with the following contents can be created in the workflows folder.

The contents

name: github actions sample

on : [Pull]

jobs :

Test-GitHub-Actions-job1:

Runs on: server-name

steps:

  • run: echo “ A Sample Workflow in GitHub Actions – Part I “
  • run: echo “ Event $ { { github.event_name } } is triggering this step “
  • run: echo “ Server $ { { runner.os } } in GitHub hosts this test application”

Test-GitHub-Actions-job2:

Runs on: server-name

steps:

  • run: echo “ A Sample Workflow in GitHub Actions – Part II “
  • run: echo “ Repository name is $ { { github.repository } } “

The above code should be committed to the GitHub repository.

Explanation

Name: github_actions_sample is the name of the workflow and it will appear in the GitHub actions repository

On: Pull – This code gets executed whenever some objects are pulled from GitHub

Jobs: Test-GitHub-Actions-job1 and Test-GitHub-Actions-job2 and the steps are defined in

When the job runs

Whenever some users try to pull out any objects from the repository the above code as part of the will get executed. This code displays the Event name, server name, and repository name.

Conclusion

Overall GitHub Actions simplifies the code management activities and shrinks the development time by automating several processes in the software development life cycle.

github actions
github
git
0 VIEWS 0 LIKES 0 DISLIKES SHARE
0 LIKES 0 DISLIKES 0 VIEWS SHARE
Was this blog helpful?
techiio-price-plantechiio-price-plantechiio-price-plantechiio-price-plantechiio-price-plan
You must be Logged in to comment
Code Block
Techiio-author
Debarghya Das
Junior Front-End Developer
Techiio-followerTechiio-followerTechiio-followerTechiio-followerTechiio-follower
+4 more
74 Blog Posts
227 Discussion Threads
Trending Technologies
15
Software40
DevOps48
Frontend Development24
Backend Development20
Server Administration17
Linux Administration26
Data Center24
Sentry24
Terraform23
Ansible83
Docker70
Penetration Testing16
Kubernetes21
NGINX20
JenkinsX17
Techiio-logo

Techiio is on the journey to build an ocean of technical knowledge, scouring the emerging stars in process and proffering them to the corporate world.

Follow us on:

Subscribe to get latest updates

You can unsubscribe anytime from getting updates from us
Developed and maintained by Wikiance
Developed and maintained by Wikiance