Joshua Avalon Blog

Trying GitHub Actions out

What is GitHub Actions?

GitHub Actions is a CI/CD service provided by GitHub. Compare to the GitLab having GitLab Runner, GitHub does not provide an official CI/CD solution before. Repositories on GitHub relies on third party CI/CD services like Travis CI, Circle CI and etc. GitHub Actions was introduced last year, they announced it will be generally available on November 13 this year.

Getting Started

To starting use GitHub Actions, you need to create a .github\workflows\<name>.yml.

Here is a example for Node.js project.

name: Main workflow
on:
  - push
  - pull_request
jobs:
  build:
    name: Build
    runs-on: ubuntu-latest
    steps:
      - uses: actions/[email protected]
      - name: Set Node.js 10.x
        uses: actions/setup-[email protected]
        with:
          version: 10.x
      - name: npm install
        run: npm install
      - name: npm test
        run: npm test
YAML
  • name: Name of the workflow that displays on GitHub.
  • on: Conditions that trigger this workflow.
  • jobs All the jobs that run in this workflow.

You can read more about different configurations here.

Steps

steps are the commands that run in a job. uses can use a GitHub action or a Docker image. A GitHub Action is a repository that contains commands to run with specific structure. For example, actions/[email protected] is master branch of actions/checkout repository on GitHub (actions is GitHub official actions).

In the above example, we checkout code from our repository, install node in the VM and run tests.

Comparison with other CI/CD services

Other than GitHub Actions, I have only used Travis CI and GitLab CI, so here is the comparison between this three.

Environment

GitHub Actions is similar to Travis CI which run jobs in a VM while GitLab Runner runs tests in a Docker container.

GitHub Actions and Travis CI provides Window and Mac environments which does not exist in GitLab Runner unless you create such Docker image. On the other hand, GitLab Runner using Docker ensure the test results are reproducible else where. I faced a test only fail on Travis CI because there are some configurations hidden in VM causing it. This make me hate running tests in VM instead of Docker.

Actions

One of the biggest features are actions that can be used in the workflow. Travis CI achieves this by provide predefine tasks. GitHub Actions are similar but more flexible. Everyone can create their actions as they are just repository. GitLab Runner can merge configurations from other repositories.

However, I don't see this is a feature. You can see that the two actions that we used are checkout and install Node.js The first one is really redundant. Why is it not checkout out the repository by default? In GitLab Runner, you can just uses node:ubuntu Docker image without installing it yourself.

While there may be some benefits using actions, I do not like this configuration. It is because the CI/CD can fail even nothing in your repository has changed if the actions changed. I believe GitHub would not break compatibility, but if you planned to you actions provided by other uses, you should be careful of it.

Performance

May be GitHub Actions is still in beta, not having to many people using it. It definitely starts up much faster than Travis CI and GitLab Runner.

Features

GitHub Actions provides basic CI/CD features but it still lacks some advance features, for example, dependencies scanning, test coverage, code quality. These features still requires third party integrations.

Self-host

GitHub Actions stated that it can be self-hosted in the future. GitLab Runner can be self-hosted. Only Travis CI cannot.

Conclusion

If we talk about CI/CD alone, I would still prefer GitLab Runner. However, if you are on only GitHub only, I do not see a reason not to use GitHub Actions.