GitHub Actions — Supercharged

· 2 min · medium

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

Strengths of GitHub Actions:

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 referenced 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:

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:

✨ 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 to 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.