This is a complete, hands-on GitHub Actions cheat sheet: install, configure, operate, automate and secure it - with copy-paste commands grouped by task. Bookmark it for day-to-day work, incidents and interviews alike.
GitHub Actions runs event-driven workflows (on push, PR, schedule, etc.) defined as YAML in .github/workflows, using reusable 'actions' from the marketplace or your own repos.
Why you reach for it
- Zero extra infrastructure - it lives where your code already is
- A marketplace of prebuilt actions for build, test, deploy and scanning
- OIDC lets workflows get short-lived cloud credentials with no stored secrets
Installation
mkdir -p .github/workflows
$EDITOR .github/workflows/ci.yml # workflows are just YAML files in the repoConfiguration reference
A CI workflow with caching and a matrix build.
name: ci
on: [push, pull_request]
jobs:
test:
runs-on: ubuntu-latest
strategy:
matrix: { node: [18, 20, 22] }
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with: { node-version: ${{ matrix.node }}, cache: npm }
- run: npm ci
- run: npm testCore commands you use daily
# Run and debug workflows locally with act
act -j test
gh run watch # follow the latest run from the CLIgh CLI for runs
gh workflow list
gh workflow run ci.yml --ref main
gh run list --workflow=ci.yml
gh run watch
gh run view --logHandy expressions & contexts
if: ${{ github.ref == 'refs/heads/main' }}
concurrency: { group: ${{ github.workflow }}-${{ github.ref }}, cancel-in-progress: true }
env: { SHA: ${{ github.sha }} }Use it in CI/CD
Deploy to AWS using OIDC - no long-lived secrets.
permissions: { id-token: write, contents: read }
steps:
- uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: arn:aws:iam::1234:role/gha-deploy
aws-region: eu-west-1
- run: aws s3 sync ./dist s3://acme-site --deleteBest-practice checklist
- Pin actions to a commit SHA and review third-party actions before use
- Use OIDC for cloud auth and set minimal permissions blocks
- Cache dependencies and split long jobs with a matrix
Common pitfalls to avoid
- Using un-pinned third-party actions (tag can move under you) - pin to a SHA
- Storing cloud keys as secrets instead of using OIDC
- Over-broad GITHUB_TOKEN permissions; scope them per job
Security quick wins
- Prefer OIDC over stored credentials; set least-privilege permissions
- Use environments with required reviewers for production deploys
Works well with
- Jenkins - The extensible automation server for CI/CD, with pipelines defined as code in a Jenkinsfile.
- GitLab CI/CD - Pipelines-as-code baked into GitLab, with built-in registry, environments and security scanning.
- Docker - Package an app and its dependencies into a portable image that runs the same everywhere.
A cheat sheet is muscle memory on paper - keep it close until the commands live in your fingers.
Want senior help putting GitHub Actions to work - or a team bootcamp on it? CodeWizard runs Israel's largest DevOps community and embeds named senior engineers with a transparent hours log. Book a free consult or explore the Academy.