Github Actions - Supercharged

Having worked with various CI/CD platforms like BitBucket, GitLab, and AWS CodePipelines, I’ve come to deeply appreciate GitHub Actions. Its implementation, in my opinion, surpasses the rest.

Strengths of GitHub Actions:

  • ♻️ Reusable workflows: This makes it easy to maintain and replicate processes across projects.
  • 👾 Concise YAML syntax: For those who grumble about indentation, a linter can be your best friend.
  • 🔁 Dedicated Repositories for Workflow Steps: Each step having its dedicated GitHub repository simplifies documentation searches and troubleshooting.
  • 🤼 Community-Driven Workflows: The community’s involvement ensures continuous improvements and a wealth of shared knowledge.

Migrating to GitHub Actions, both for personal and professional projects, has been a mostly seamless experience. There were occasional bumps, like misplaced artifact locations, but the overall impression remains positive. So, where are the pitfalls?

The Challenges with GitHub Actions

Imagine assembling a flat-pack furniture item. The instructions are clear, and assembling the pieces feels intuitive. However, ensuring that you’ve used the right screw or bolt in the correct location can be a tedious process. To know if you did it right, someone would need to stress-test the assembled piece. Not the most efficient method, right?

Consider this GitHub Actions step:

    steps:
      - name: Checkout repository
        uses: actions/checkout@v3
        with:
          ref: ${{ inputs.relase-tag }}

Did you spot the issue? Despite inputs containing a release-tag, it’s mistakenly labeled as relase-tag.

Result? A failed build 🤦.

Tools to the Rescue

There are some great tools out there that can help avoid the dreaded Process completed with exit code 1 error.

✨ 1) Actionlint

Actionlint is a robust static checker for GitHub Actions workflow files. It ensures your definitions are valid and sidesteps common pitfalls. Its features include:

  • Expressions Checks: It ensures that GitHub Actions' special expression syntax, ${{ }}, is correctly formed

  • Syntax Verification: Useful for identifying basic YAML syntax errors

  • Dependency Checks: It verifies your job dependencies to ensure that ‘needs’ references in a job correctly point to an existing job

  • Schema Validation: Confirms that events, jobs, and steps are correctly defined

Download the binary from its official repository and run actionlint in your workflow directory. Its swift analysis makes it an ideal addition to git hooks.

✨ 2) VS Code Extension - GitHub Actions:

This extension for VS Code enhances your GitHub Actions experience by:

  • Offering Autocomplete and IntelliSense for GitHub Actions YAML.

  • Providing an Intuitive Interface to visualize workflows, view run details, and get immediate status feedback.

  • Showcasing Inline Error and Warning Annotations directly in the editor.

✨ 3) nektos/act:

Want to emulate GitHub Actions on your local machine? nektos/act is your solution. It offers rapid feedback without the need for pushes, and for those mindful of costs, it’s a saver 💰.

The tool utilizes Docker containers to emulate GitHub Actions runners, ensuring environment consistency. However, bear in mind that sometimes these containers may lag behind the continually evolving GitHub ecosystem. But for experimentation specific with GHA? It’s an excellent tool which creates a rapid feedback loop. There’s a great guide to get running here

Conclusion

Harnessing the power of GitHub Actions combined with these tools can streamline your CI/CD process. By preemptively catching errors and refining workflows, you’ll spend less time troubleshooting and more time deploying.

Ash Grennan
Ash Grennan
Snr Software Engineer

Deliver value first, empower teams to make technical decisions. Snr Engineer @ Moonpig, hold a BSc & MSc in software engineering & certified AWS Solutions Architect (LinkedIn). A fan of Serverless computing, distributed systems, and anything published by serverless.com 🧡