A beginner’s guide to CI / CD and automation on GitHub

The first time I saw the CI / CD pipeline working was the moment of real awakening. I worked for a company that used GitHub Actions to reduce the release time to 5 minutes. Also, if you run into problems, you can roll back the release at the push of a button.

At that time, I had just finished my job at a startup. There, the release process was much more manual and much more disturbing. We were a small team and could only release updates if users were unlikely to use the app at midnight without the benefits of CI / CD pipelines and turquoise deployments. This is a tedious process, and with some human error, it takes a long time to deploy the build.

Still, CI / CD’s first experience turned buzzwords into concrete and impressive, backed by automated workflows running on GitHub Actions. Now, with an interesting twist, I’m working on GitHub, where GitHub Actions is my personal focus.

Therefore, for those who are just getting started with CI / CD and workflow automation on GitHub, we would like to turn the experience of introducing GitHub Actions into a resource.

let’s start.

So what exactly is a GitHub action?

For beginners or anyone who has heard of it but doesn’t fully understand it, GitHub Actions is a native CI / CD tool that runs with your GitHub code. In fact, at some point you may have noticed a tab labeled “Actions” in your GitHub repository (hint: where the GitHub action resides).

Screenshot showing the GitHub Actions tab in the repository

The first time you open this tab, you’ll see what a GitHub action is and a brief description of the recommended workflow for your repository. The fun begins from there. For GitHub Actions Over 13,000 pre-created and tested CI / CD workflows and pre-built automation on the GitHub MarketplaceAnd the ability to create your own workflow (or customize an existing workflow) with an easy-to-use YAML file.

Screenshot of the introductory screen that the developer sees the first time they open GitHub Actions in the repository

I’ll show you how to build your own GitHub Actions workflow later, but I’ll leave that for now. GitHubActions workflows can be designed to respond to any webhook event on GitHub. That is, you can turn any webhook on GitHub into a trigger for automation in your CI / CD pipeline. This includes third-party webhook events.

The concepts behind the GitHub Actions workflow

So I’ve talked a bit about the GitHub Actions workflow, but sometimes it’s easiest to see the actual workflow (which is intended for puns).

Screenshots of an example GitHub Actions workflow

Screenshots of an example GitHub Actions workflow

The workflow above consists of several different things. These include:

  • runner: The runner is a GitHub Actions server. Each runner can be hosted on GitHub or self-hosted on a localized server. The runners hosted on GitHub are based on Ubuntu Linux, Windows, and macOS, which you can specify in your workflow.
  • event: An event is a predefined trigger that starts a workflow.
  • Jobs: A job is a series of steps performed by the same runner.
  • procedure: Steps are individual tasks that execute commands in a job. These can be actions or shell commands.
  • Action: Actions are commands executed by the runner and are also a core element of GitHub Actions named after them.

Putting all these concepts together, you get the following workflow:

on:   issues:     types: [opened] jobs:   comment:     runs-on: ubuntu-latest     steps:      - name: Rick Roll       uses: TejasvOnly/random-rickroll@v1.0       with:         percentage: 100

(For reference, this is Fun GitHub action workflow In theory, you could create part of a CI / CD pipeline. I’ll post a Rick Astley GIF as a comment on all the new issues that open in the repository. Scientifically proven to enhance your productivity and general enjoyment.. i promise. )

Common use cases for GitHub actions (and why you need to be careful)

In my experience, there are four common ways to use GitHub actions (don’t worry, they include a link to a pre-made workflow that you can drop into the repository and start using immediately. ). These include:

CI / CD GitHub action workflow

At this point, it’s not surprising to hear that the powerful and common use cases of GitHub Actions revolve around CI / CD.

It’s far from the only CI / CD platform out there (and you can integrate almost any CI / CD platform into your GitHub workflow), but with the benefits of tight integration and triggering capabilities with other GitHub platforms. There is any part of the CI / CD pipeline away from any webhook on GitHub.

Here are some useful, pre-built GitHub Actions CI / CD workflows that you can use to get started.

  • Node.js continuous integration: This workflow performs a clean installation of node dependencies, caches and restores them, builds source code, and runs tests on different versions of the node to reduce human error. It’s specific to Node.js, but there are other workflows for other programming languages, all of which are very useful.
  • Run end-to-end tests in your code base: Whether you use Cypress, Applitools, or Mabl to run end-to-end UI tests in your application, there is a GitHub Actions workflow. Try including these GitHub actions in your repository to trigger a test run before merging your code into production.
  • Deploy the container image to Amazon ECR: This workflow builds a new container image, pushes it to Amazon ECR, and when pushed to the default branch, deploys the new task definition to Amazon ECS. Note that similar GitHub actions exist on different platforms such as Terraform and Google Cloud Platform.

GitHub action workflow for release management

Release management is an important part of the CI / CD pipeline. However, you can also automate the release without a fully baked CI / CD pipeline. Whichever path you choose, here are two GitHub action workflows that can be very helpful in taking your approach to release management to the next level.

  • Roll back or delete the release if an error occurs: We were all there. We have released new features or bug fixes that cause more problems. From time to time, I even brought down the retail version (it happens). This action makes it easy to initiate a rollback if an error is found in the release. This saves time so you can start working on fixing build issues.
  • Automatic publishing of npm packages: This action automatically publishes the npm package when you push the code to the specified branch. At first glance, it’s simple, but it guarantees that you’ll save a lot of time.

GitHub Actions workflow for third-party integration

Whether you’re talking about part of the CI / CD pipeline or part of a normal workflow, you may be using multiple tools when writing your code. Making sure that all these tools are integrated with each other can be one of the less interesting parts of your development work, but it’s an important step.

Here are two types of workflows that are very useful for beginners.

  • Send a notification to Slack: This action helps keep your frequently used communication tools up to date (if you’re using Microsoft Teams) There is also an action for that). You can use this action to notify you about releases, build failures, CI / CD processes, newly opened pull requests, and more.
  • Connect the project planning board to the repository: Whether you’re using Jira, Trello, or GitHub issues, you can leverage a number of GitHub action workflows to integrate them into your project. This means that if the build fails or succeeds, you can automatically trigger new issues and comments about the issues. The same is true for testing. This personally helps me keep track of what works and what doesn’t with automatic updates to the project planning board.

GitHub Actions workflow for community and team management

Talking to open source maintainers and corporate people, I’ve often heard how long it takes to maintain an active project, team, or community. In addition to CI / CD, GitHub Actions is a great tool for automating repetitive but often manual tasks within your organization and managing projects and teams on a large scale.

In that sense, here are some useful GitHub Actions workflows I’ve come across:

  • I take action: This simple workflow allows contributors or team members in a project to assign themselves to a problem. You can also configure it to explain the project’s technology, provide guidelines, or thank someone for taking on the issue, and comment on issues with preloaded content.
  • First interaction: This workflow welcomes first-time contributors to the repository with self-configurable preloaded messages. This is a great way to get new team members and contributors involved and make sure everyone has a basic understanding of the project before contributing to the project.
  • Invite me: It might be more convenient for the open source community, but I personally love this workflow. If a collaborator comments on an issue, invite the collaborator to a public agency. This allows collaborators to be responsible for receiving and accepting invitations.

I would like to tell you a little more in case the above workflow is not busy.In us Starter workflow repositoryYou can find a bunch of pre-built GitHub actions that you can use out of the box for continuous integration, continuous deployment, code scanning, and workflow automation. All of these workflows have been built and tested by the GitHub team and are updated regularly.

One of my personal favorites CodeQL, This will integrate GitHub’s static code analysis engine into your workflow and identify known security vulnerabilities in your code. There are also many other pre-built workflows for the many things you may be working on.

  1. Create a .github / workflows folder in your repository.
  2. Create a .yml file in that folder.
  3. Copy the contents of the prestarter workflow and paste it into a .yml file.
  4. Customize the file as needed.
  5. Trigger an action to test it run successfully.

Advanced Tips: Customize pre-made GitHub Actions workflows to suit your needs

With over 13,000 GitHub actions in the GitHub marketplace, you may not need to create a workflow from scratch, as it may already exist. Still, you’ll find a nearly perfect workflow a few times, but you’ll need to make a few adjustments to fit your needs perfectly.

In this situation, you can create a new workflow or customize a pre-made workflow. Also, if you don’t know how to customize your workflow, read this article I’ve put together.

Find out how to customize a pre-made GitHub Actions workflow

Learn how to build your own GitHub action workflow

It can be easy to learn by seeing someone else doing something in real time. So if you’re trying to build your own GitHub Actions workflow, watch this video to learn how to build your own actions within 10 minutes.

Additional resources A beginner’s guide to CI / CD and automation on GitHub

Back to top button