AI Hints
Home›CI/CD with GitHub Actions Tutorial›Beyond Actions and Best Practices
CI/CD with GitHub Actions · Lesson 126 of 138

Common Mistakes

And how to avoid them.

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

Everyone makes the same few CI mistakes at first. Let's look at them, so you can spot them quickly. Some are typos, and some are habits.

Common Mistakes
From the video: Common Mistakes
  • Everyone makes them
  • Spot them fast
  • Typos and habits

Typos actionlint finds

Here's a workflow with two typos. Actionlint finds both. The runner label ubuntu lates, is missing a T. And deploy needs a job called tests, but the job is called test. On GitHub, both would only show up after you push.

Terminal
actionlint -format '{{range .}}{{.Message}}|{{end}}' .github/workflows/ci.yml | tr '|' '\n' | cut -d. -f1
label "ubuntu-lates" is unknown
job "deploy" needs job "tests" which does not exist in this workflow

Habits to avoid

And some habits to avoid. Rerunning red builds until they pass. Printing secrets, or putting untrusted text into scripts. Using latest for deployments. And pipelines so slow that people stop waiting for them.

MistakeInstead
Re-run until greenfix the flaky test
Secrets in logsnever print them
Deploy :latestdeploy sha- tags
Slow pipelinescache, split, skip

Mistakes that are easy to miss

Forgetting the checkout step, so the job has no code to test. Running a command in the wrong folder, when the project lives in a subfolder. Expecting secrets in pull requests from forks, where they're empty on purpose. And forgetting permissions, so a step that comments or publishes gets a forbidden error.

keyvalue
No checkoutno code in the job
Wrong folderworking-directory
Fork PRssecrets are empty
403 errorsadd permissions

Summary

Lint your workflows, and avoid the habits that destroy trust. Next, interview questions about CICD.

Key takeaways
  • actionlint first
  • Don't re-run red
  • Never deploy latest
Next up: Interview Question 1 — CI versus CD