GitHub Actions: Rise of the Machines (Automating CI, Workflow, and More on Your Favorite Open Source Platform)
Published: 2021-05-21 22:22:19

There’s good reason for Github’s ubiquity in the world of development. Its open source structure reflects what’s best about the web: free, accessible, and communal. It’s a habitat for tech giants like Facebook and rogue bands of hackers alike. Curious developers can dive deep into source code, point out bugs and suggestions, and fork public repositories to version things as they see fit. Of course, the way Github sits within the larger world of app development and publication is fairly patterned. Projects born on Github eventually move into a production environment or are published to a platform like NPM. To simplify this process, there’s Github Actions.

Github Actions is a range of automation services for increasing the functional breadth of your codebase. Developers can identify a specific workflow that is repetitive or time consuming and design a way to automate the process. Think of a Github Action as an event listener for a repo. If a specific action is taken, then the specified reaction occurs.

These actions and reactions are laid out in a YAML file, but first the user must specify a new workflow. This process begins under the Actions tab on a repo’s main page. Here a list of popular template workflows are available. Developers can also simply build a workflow from scratch. Whether a custom workflow is selected or a template, Github will launch a new YAML file nested in a .github/ folder in the main project directory. A YAML file takes on the following format:

```
name: learn-github-actions
on: [push]
jobs:
  runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
      - uses: actions/setup-node@v1
      - run: npm install -g bats
      - run: bats -v
```

Some of the basic commands/features of a Github Actions YAML are as follows:
* Name: an optional attribute for IDing the action
* On: this is the action you’re listening for. It can be a merge, a feature request, bug report, or any interaction that takes place with a repo or within an organization
* Jobs: the list of commands to execute when an On event is triggered. 
* Runs-On: establishes the type of virtual machine Github will use to execute the following commands. 
* Steps: this is a sequence of actions to work through sequentially
* Run: an executable command for the virtual machine terminal

The most common usage of Github Actions is continuous integration, but there are several other popular uses. In addition to publishing libraries to NPM or Github Packages, Github offers template Actions for deployment. To achieve complex tasks, Github publishes a number of popular workflows developers can use. Think of these as dependencies for a specific action. The checkout action, for example, does exactly what it says. It pulls a specified repository or branch into the virtual machine for the steps that follow.

This open source approach to some of the more tedious aspects of app development can really simplify the software development and deployment process. Github Actions is capable of deploying on all major platforms, and, because of the use of virtual machines, can be utilized for practically any language or configuration necessary. If a project already lives on Github, configuring automations with Actions couldn’t be easier.