Tool cheatsheet
GitHub Actions 1 Cheatsheet
Workflow YAML snippets for triggers, jobs, caching, secrets, matrices, artifacts and deployment.
Workflow basics
- Minimal workflow — A workflow file in .github/workflows/ that runs tests on every push and pull request.
- Run only when certain files change — Limit a trigger to changes under given paths.
- Run on a schedule — Run at 03:00 UTC every day. Scheduled times use UTC cron syntax.
- Run manually with inputs — Add a Run workflow button with an input.
- Set environment variables — Define variables for a workflow, job or step.
- Run several commands — Use a block scalar to run a multi-line script in one step.
- Set a job timeout — Stop a job that hangs, instead of waiting for the six-hour default.
Languages, caching and artifacts
- Set up Node.js with caching — Install a Node.js version and cache npm downloads.
- Set up Python with caching — Install Python and cache pip downloads.
- Cache files between runs — Cache any folder, keyed by a hash of a lock file.
- Upload a build artifact — Save files from a job so you can download them or use them in a later job.
- Download an artifact in another job — Fetch an artifact produced earlier in the workflow.
Jobs, matrices and conditions
- Test across versions — Run the same job once per Node.js version and operating system.
- Run jobs in order — Make one job wait for another to succeed.
- Run a step conditionally — Run a step only on the main branch.
- Run a step after a failure — Run cleanup or notifications when an earlier step failed.
- Cancel outdated runs — Cancel an in-progress run when a newer one starts for the same branch.
- Start a database for tests — Run a PostgreSQL container next to the job.
- Pass data between jobs — Expose a step's output as a job output that later jobs can read.
Secrets and security
- Use a secret — Read a repository secret. Secrets are masked in logs.
- Limit the token's permissions — Give GITHUB_TOKEN only the access the workflow needs.
- Require approval for a deployment — Target an environment that has protection rules, such as required reviewers.
- Pin an action to a commit — Use a full commit SHA instead of a tag so a retagged action can't change under you.
Reuse and deploy
- Define a reusable workflow — Make a workflow callable from other workflows.
- Call a reusable workflow — Run a reusable workflow from a job.
- Build and push a Docker image — Log in to GitHub Container Registry and push an image tagged with the commit SHA.
- Create a release from a tag — Create a GitHub release with generated notes using the preinstalled gh CLI.
Related cheatsheets
- Ansible 2 cheatsheet — Run ad-hoc commands and playbooks, manage inventories, roles, collections and secrets with Ansible.
- Argo CD 3 cheatsheet — Install Argo CD, define Applications declaratively, and manage sync, diffs, history and rollbacks with the argocd CLI.
- AWS CLI 2 cheatsheet — Configure credentials and manage S3, EC2, Lambda, logs, containers and secrets with the AWS CLI v2.
- Azure CLI 2 cheatsheet — Sign in and manage resource groups, VMs, web apps, storage, Kubernetes, registries and secrets with the az command.
- Bash and Linux 5 cheatsheet — Everyday shell and Linux commands for files, searching text, permissions, processes and servers.
- Claude API cheatsheet — Call Claude from Python, TypeScript or curl: messages, streaming, thinking, tools, structured output, caching, batches and error handling.