GitHub Actions - Process Automation
Tags: continuousdeployment, github, githubactions, ci
Published: 2024-02-13 17:00:00

*An introduction to process automation using [GitHub Actions](https://github.com/features/actions)*

*[Article in spanish](https://dev.to/hozlucas28/github-actions-automatizacion-de-procesos-566j)*

![Official GitHub Actions logo composed of five interconnected circles.](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/5fatnbjc2bkjfpdputfh.png)

> [GitHub Actions](https://github.com/features/actions) logo

## Introduction

In the world of software development, automation has become a crucial element for code efficiency and quality. [GitHub Actions](https://github.com/features/actions) emerged with the goal of fulfilling this task.

In this article, we will explore how [GitHub Actions](https://github.com/features/actions) create the necessary workflows to tackle the challenging task of automating processes.

## Table of contents

- What are GitHub Actions?
- What is a Workflow?
- Creating your first Workflow
- Customization and advanced configuration
- Integration with external platforms
- Benefits and use cases
- Conclusions
- Related resources

### What are GitHub Actions?

[GitHub Actions](https://github.com/features/actions) is a set of tools, referred to as "Actions", integrated into [GitHub](https://github.com/). These actions enable the automation of common processes, such as running tests, compiling code, and deploying applications from [GitHub](https://github.com/). Turning [GitHub Actions](https://github.com/features/actions) into a fundamental service for streamlining and improving software quality.

### What is a Workflow?

A workflow in [GitHub Actions](https://github.com/features/actions) is a series of automated jobs that run in response to specific events in the associated repository. These events can include actions like code [commits](https://docs.github.com/pull-requests/committing-changes-to-your-project/creating-and-editing-commits/about-commits), opening [pull requests](https://docs.github.com/pull-requests/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/about-pull-requests), or even publishing new [releases](https://docs.github.com/repositories/releasing-projects-on-github/about-releases). Workflows allow organizing and coordinating the actions of [GitHub Actions](https://github.com/features/actions) involved to achieve the desired goal.

### Creating your first Workflow

Creating a workflow in [GitHub Actions](https://github.com/features/actions) does not require extensive knowledge. You can start with a workflow that runs tests every time a code [commit](https://docs.github.com/pull-requests/committing-changes-to-your-project/creating-and-editing-commits/about-commits) is pushed to the main [branch](https://docs.github.com/pull-requests/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/about-branches) of the repository. Create a file named `.github/workflows/build-and-test.yml` and define its properties.

> A file with a `.yml` extension ([YAML](https://yaml.org/)), created within the `.github/workflows` directory, defines a workflow for [GitHub Actions](https://github.com/features/actions). In it, the actions to be executed, the triggering events, and how it will interact with the repository are established

```yaml
name: Build and Test

on:
  push:
    branches:
      - main

jobs:
  build:
    runs-on: ubuntu-latest

    steps:
    - name: Checkout repository
      uses: actions/checkout@v4

    - name: Set up NodeJS
      uses: actions/setup-node@v4
      with:
        node-version: '20'

    - name: Install dependencies
      run: npm ci

    - name: Run tests
      run: npm run test
```

> Example of `.github/workflows/build-and-test.yml` file

### Customization and advanced configuration

[GitHub Actions](https://github.com/features/actions) allows advanced customization of workflows. You can define matrices to run actions in different [environments](https://docs.github.com/actions/deployment/targeting-different-environments/using-environments-for-deployment), configure [environment variables](https://docs.github.com/actions/learn-github-actions/variables), and use [community actions](https://github.com/marketplace?type=actions) to integrate specific tools. This provides granular control over how actions are executed and adapts to the specific needs of the project.

### Integration with external platforms

One of the highlighted features of [GitHub Actions](https://github.com/features/actions) is its ability to integrate with other platforms and services. You can use predefined actions to deploy to cloud services, like: [AWS](https://aws.amazon.com/), [Azure](https://azure.microsoft.com/), or [Google Cloud](https://cloud.google.com/). Additionally, the [GitHub Actions API](https://docs.github.com/rest/actions?apiVersion=2022-11-28) allows integration with custom tools and services.

### Benefits and use cases

Automation with [GitHub Actions](https://github.com/features/actions) brings numerous benefits to software development. It accelerates continuous delivery ([CD](https://en.wikipedia.org/wiki/Continuous_delivery)), improves code quality by automatically running tests, and facilitates deployment in various environments. Common use cases include building and deploying web applications, running integration tests, and notifying changes in external services.

A practical example would be checking [pull requests](https://docs.github.com/pull-requests/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/about-pull-requests) through a workflow triggered for each [pull request](https://docs.github.com/pull-requests/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/about-pull-requests).

![Execution of a workflow from a GitHub Action, checking a pull request. Four successful jobs can be observed: check title, get committed files, check committed files, and finally, check committed file.](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/9yoi01pil48xodrral52.png)

> Example of a workflow that checks a [pull request](https://docs.github.com/pull-requests/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/about-pull-requests)

## Conclusions

[GitHub Actions](https://github.com/features/actions) has proven to be a valuable tool for automation in software development. From simplifying routine tasks to facilitating complex workflows, [GitHub Actions](https://github.com/features/actions) improves efficiency and quality in projects of all sizes. Integrating this tool can make a difference in the speed and reliability of your software deliveries.

## Related resources

- [Free GitHub and Microsoft course to learn GitHub Actions](https://learn.microsoft.com/collections/n5p4a5z7keznp5)
- [GitHub Actions official page](https://github.com/features/actions)
- [Official GitHub Actions documentation](https://docs.github.com/actions)
- [Official guides of GitHub Actions](https://docs.github.com/actions/guides)