Mastering GitHub Actions: A Complete Guide to CI/CD Automation

What is GitHub Actions?

GitHub Actions is a platform which allows you to automate the developer workflows.
Workflows such as :-

  1. Continous Delivery
  2. Continous Deployement
  3. Automation
  4. Security

GitHub Actions are Similar to Devops but has much wider coverage in terms of any automation. It allows you to automate any event that happens in the repository and perform certain automated actions.

Core Components of GitHub Actions

GitHub Actions workflow can be triggered when an event occurs into the repository such as pushing change into master, creating pull request against master, creating/publishing your changes. Workflow contains one/multiple actions which can run sequential or parallel on there dedicated machines/containers.

1. Workflow

Workflow is a configurable process that will run one or more jobs. Workflows are often defined into a yaml/yml file which are part of you repository and can be triggered on an event.
All workflows are defined under .github/workflows directory in the repository.
Each workflow can perform different tasks as :-

  • Building an application
  • Testing an application/changes
  • Deploying your changes after every release.
  • Adding label in Jira when ticket is opened.

2. Events

Event can be defined as an activity which triggers a workflow inside the repository. Any event can also be triggered at a specific time.

3. Jobs

A job is a set of steps in a workflow that is executed on the same runner. Each step can be a shell script or an action. These steps are executed in order and are dependent on each other. Since all these steps are on same runner data can be shared between them. For Example you can have a step that build your application followed by a step that tests the application.

4. Actions

An action is a custom application for GitHub actions platform that performs a complex but frequently repeated task. It helps in code re-usability of repeated tasks. An action can pull your Git repository from GitHub, set up the correct toolchain for your build environment , or set up the authentication to your cloud provider.
You can also write your own actions, or you can find actions to use in your workflows in the GitHub Marketplace.

5. Runner

runner is a server that runs your workflows when they’re triggered. Each runner can run a single job at a time. GitHub provides Ubuntu Linux, Microsoft Windows, and macOS runners to run your workflows. Each workflow run executes in a fresh, newly-provisioned virtual machine.

GitHub Actions YAML Workflow Example

Now Lets understand below workflow example . This workflow builds the project Java Project with maven as build tool on certain actions like push/pull into the repository.
name – Defines the workflow name
on – Event on which workflow will be triggered
jobs – set of steps which will be executed for current workflow
runs – Defines the runner on which all steps will run
actions – pre-defined keyword for invoking different actions
steps – dependent steps which are scripts or pre-defined actions.

GitHub Actions vs Jenkins Pipelines: Key Differences

Over traditional Jenkins pipelines GitHub Actions provides many advantages

FeatureGitHub ActionsJenkins Pipeline
SetupConfiguration is in Simple yaml Files.Configuration is done in Groovy Scripting Language.
IntegrationActions are natively integrated with GitHub.Jenkins needs hooks and explicit CI/CD Servers.
FlexibilityEverything is event based. Which are flexible in nature.Flexible but configuration is needed for each and every step.
MaintenanceManaged by dev team as part of application code.Devops teams are needed to manage.



Comments

9 responses to “Mastering GitHub Actions: A Complete Guide to CI/CD Automation”

  1. […] thedevopsguy.co.in in Blog Git Workflows Deployment Tools GitHub Actions […]

  2. I truly appreciate this post. I¦ve been looking all over for this! Thank goodness I found it on Bing. You have made my day! Thank you again

  3. Thanx for the effort, keep up the good work Great work, I am going to start a small Blog Engine course work using your site I hope you enjoy blogging with the popular BlogEngine.net.Thethoughts you express are really awesome. Hope you will right some more posts.

  4. Simply a smiling visitor here to share the love (:, btw great design. “Justice is always violent to the party offending, for every man is innocent in his own eyes.” by Daniel Defoe.

  5. I’ve read some good stuff here. Certainly worth bookmarking for revisiting. I wonder how much effort you put to make such a excellent informative web site.

  6. Hello my loved one! I wish to say that this post is amazing, great written and come with almost all important infos. I would like to look more posts like this .

  7. Some really interesting points you have written.Aided me a lot, just what I was searching for : D.

  8. Thanks for a marvelous posting! I certainly enjoyed reading it, you are a great author.I will always bookmark your blog and will often come back later in life. I want to encourage you continue your great work, have a nice morning!

  9. Hello, Neat post. There’s a problem with your web site in internet explorer, would test this?K IE still is the marketplace chief and a good portion of folks will leave out your magnificent writing because of this problem.

Leave a Reply

Your email address will not be published. Required fields are marked *