AI Hints
CI/CD with GitHub Actions · Lesson 29 of 138

Checking Workflows

Actionlint.

⏱ 2 min read▶ Video at 32:44🎓 Free
Watch this lesson in the CI/CD with GitHub Actions courseWatch on YouTube ↗Full CI/CD with GitHub Actions course

Workflow files can have mistakes too. A misspelled key, a wrong runner name, or a broken expression. On GitHub, you'd only find out after pushing. A tool called actionlint checks workflow files on your own machine, in a second.

Checking Workflows
From the video: Checking Workflows
  • Workflows have bugs too
  • Found after pushing?
  • actionlint checks them first

Spot the mistakes

This workflow has three mistakes. Pause, and see how many you can find. Look carefully at the push settings, the runner name, and the last expression.

.github/workflows/ci.ymlyaml
name: CI
on:
  push:
    branch: [main]
jobs:
  test:
    runs-on: ubuntu-lates
    steps:
      - uses: actions/checkout@v4
      - run: pytest -q
        name: Run tests
      - run: echo ${{ github.sha }

actionlint finds them

Actionlint reports each problem, with its line and column, and cut trims the very long lines to fit. Branch should be branches. Ubuntu lates isn't a known runner. And the expression on the last line is missing a closing brace. Each message explains what's wrong, so fixing them takes seconds.

Terminal
actionlint -no-color -oneline | cut -c1-100
.github/workflows/ci.yml:4:5: unexpected key "branch" for "push" section. expected one of "branches"
.github/workflows/ci.yml:7:14: label "ubuntu-lates" is unknown. available labels are "windows-latest
.github/workflows/ci.yml:12:35: got unexpected EOF while lexing end marker }}, expecting '}' [expres

Summary

Actionlint checks workflow files for mistakes before you push. Run it often, or even in CI itself. Next, push and pull request triggers.

Key takeaways
  • actionlint
  • Line and column
  • Fix before pushing
Next up: Push and Pull Request Triggers — which events, when