← All insightsCheat Sheet

GitHub Actions cheat sheet: the complete command reference

CodeWizard Engineering · 9 July 2026 · 3 min read · Beginner

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

bash
mkdir -p .github/workflows
$EDITOR .github/workflows/ci.yml   # workflows are just YAML files in the repo

Configuration reference

A CI workflow with caching and a matrix build.

yaml
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 test

Core commands you use daily

bash
# Run and debug workflows locally with act
act -j test
gh run watch    # follow the latest run from the CLI

gh CLI for runs

bash
gh workflow list
gh workflow run ci.yml --ref main
gh run list --workflow=ci.yml
gh run watch
gh run view --log

Handy expressions & contexts

yaml
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.

yaml
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 --delete

Best-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.

Like where this is going?

Get hands-on help from the engineers who write these posts.

Book a free consult