AI Hints
Home›CI/CD with GitHub Actions Tutorial›Cheat Sheets and Final Quiz
CI/CD with GitHub Actions · Lesson 131 of 138

Cheat Sheet: Patterns

Recipes to reuse.

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

Now the patterns, the small recipes that solve common problems. Each one is something we built in this course.

Cheat Sheet: Patterns
From the video: Cheat Sheet: Patterns
  • Small recipes
  • Common problems
  • All from this course

Pipeline patterns

Here are the pipeline patterns. Fast gates first, then slower ones. A gate job that needs everything, for branch protection. A matrix for versions. And caching for dependencies.

NeedPattern
Fast feedbacklint → test → build
One required checkgate job, needs: all
Many versionsstrategy.matrix
Faster installscache: pip / npm

Delivery patterns

And the delivery patterns. Build once, and tag with the SHA. Deploy to staging, then production with approval. Release when a version tag is pushed. And roll back by redeploying the previous tag.

NeedPattern
Same artifactbuild once, sha- tag
Safe releasesstaging → approval → prod
Releaseson: push: tags: v*
Undoredeploy previous tag

Security patterns

Finally, security. Least privilege permissions. Untrusted text through env. Actions pinned to SHAs. And OIDC for clouds.

RiskPattern
Token abusepermissions: per job
Script injectionenv: then $VAR
Moved tagspin to a SHA
Cloud keysOIDC

Debugging patterns

And a few debugging recipes. Set dash X to trace commands. To JSON to print a context. The step debug secret for detailed logs. And actionlint before every push.

ProblemPattern
What ran?set -x
What values?toJSON(github)
Need more detailACTIONS_STEP_DEBUG
Syntax mistakesactionlint

Summary

Gates, matrices, caches, build once, staged releases, and secure defaults. Next, the final quiz.

Key takeaways
  • Gates and matrices
  • Build once, promote
  • Secure defaults
Next up: Final Quiz — the whole course