Sitemap

GitHub Actions Overview

6 min readNov 6, 2023

--

GitHub Actions serves as a versatile automation solution and workflow management tool within the GitHub ecosystem, which is widely used for version control and collaborative software development. With GitHub Actions, you can streamline and automate different facets of your software development lifecycle by crafting personalised workflows through YAML configuration files that reside in your GitHub repository.

These workflows are responsive to a range of triggers, including code commits, pull requests, issue generation, or even scheduled tasks. In essence, it empowers you to automate routine tasks and processes, ensuring smoother and more efficient development, testing, and deployment of your software projects.

Git, GitHub, GitHub actions:

In simple terms, GitHub is a company that offers cloud-based storage for code. To grasp how GitHub facilitates this, it’s crucial to recognise that the name “GitHub” contains the word “Git.” Git is a separate, standalone tool that’s fundamental to understanding what GitHub is all about. So, what exactly is Git?

What is Git?

Git is a cost-free version control system tool that you can freely download and set up on your computer, regardless of whether you’re using Windows, macOS, or Linux. This Git tool empowers you to oversee modifications in the source code of applications or websites you’re developing.

Press enter or click to view image in full size

What is GitHub?

GitHub is a company that provides cloud-based Git repositories for code management. In Git, a repository is a space for your code, and you can have local repositories. GitHub lets you create and connect cloud repositories, ensuring code safety and accessibility.

It offers public and private repositories with access controls. Beyond code storage, GitHub offers collaborative features like issues, projects, and pull requests for tracking, reporting, organising, and suggesting changes, making it a platform for both storing and developing code in the cloud.

Press enter or click to view image in full size

What is GitHub actions?

GitHub Actions is that service provided by GitHub that enables you to automate code.

or build/deployment and repository management related processes, and workflows.

Press enter or click to view image in full size

Key elements in GitHub actions:

To kickstart your journey with GitHub Actions, let’s delve into the foundational elements you need to grasp.

There are three core building blocks: Workflows, Jobs, and Steps. Workflows are attached to your GitHub repositories, and you can create as many as needed for a repository. Within workflows, you define Jobs, each comprising one or more Steps executed sequentially. Steps are where the actual tasks are specified, such as code download, dependency installation, and running tests.

These elements form the basis for setting up automation processes with GitHub Actions, and you can customise them to suit your project’s requirements, providing flexibility and control.

Press enter or click to view image in full size
Github actions-key elements

Workflows:

As previously mentioned, workflows are linked to GitHub repositories and can contain multiple jobs. The critical aspect, however, is using workflows and jobs to establish automated processes. With GitHub Actions, you don’t want these processes to run continuously; instead, you associate “triggers” or “events” with your workflows.

These events dictate when a workflow should execute. For instance, you can set up an event that demands manual initiation or another event that automatically triggers a workflow whenever a new commit is pushed to a specific branch.

Press enter or click to view image in full size

Jobs:

Jobs, located within events, contain the specific steps to execute. Each job defines a “runner,” the machine and operating system for these steps. GitHub Actions provides default runners for Linux, macOS, and Windows, or you can configure your custom runners.

Jobs outline the steps executed on the specified machine. Workflows can have one or multiple jobs, which typically run in parallel but can be configured for sequential execution. You can also create conditional jobs, triggering only when specific conditions are met.

Steps:

The heart of the action lies in the “steps.” Steps are integral to jobs, and a job can encompass one or multiple steps. A step can take the form of a shell script or a command-line operation. You’ll also encounter “actions,” which are prebuilt scripts designed for specific tasks. You have the flexibility to craft your actions or leverage third-party ones.

Get Kaviram Jk’s stories in your inbox

Join Medium for free to get updates from this writer.

While a job must include at least one step, it typically involves multiple steps executed sequentially. Furthermore, steps can be conditional, ensuring adaptability to various scenarios.

Press enter or click to view image in full size

Let’s look at a Simple example to understand workflow structure and create one work flow.

To get started with GitHub Actions, you’ll need a GitHub repository. GitHub Actions are configured using YAML syntax. Here’s a step-by-step process:

  1. Existing Repository: Assuming you already have a GitHub repository with code on the master branch.
  2. Create Directory: Within your GitHub repository, create a directory named “.github/workflows”
  3. Add YAML File: Inside the “.github/workflows” directory, add a YAML (.yml) file. This YAML file is where you’ll define the GitHub Actions workflow specific to your project.

Click on Add File > Create New File

Press enter or click to view image in full size
Press enter or click to view image in full size

Next, you can insert your code into the “deployment.yml” file and save these changes by committing them to your GitHub repository.

Sample yml file :

Press enter or click to view image in full size
Sample yml file

Git hub actions UI:

You can see your workflow steps and thier execution status on interface

  1. Go Actions
Press enter or click to view image in full size

2.On the left you can see All the workflows you configured

3.You can see the recent workflow executions and their status

Press enter or click to view image in full size

4. Click on the execution to see the flow and steps:

Press enter or click to view image in full size
Press enter or click to view image in full size

Incase of Any failures the status would be shown with console logs:

Press enter or click to view image in full size

Important Links:

Triggers/Events

Expressions

Checkout

Actions

Summary:

In conclusion, this blog provides an overview of GitHub Actions. By reading this, you should have gained insights into how actions function, their configuration, and their practical use in everyday tasks. Part 2 will explore more intriguing topics, including conditional steps/jobs, continuing on errors, running jobs in containers, security, permissions, and more. Stay tuned for the next instalments!

Kaviram Jayaraman.

Automation Engineer

--

--