GitHub Actions Cheat Sheet

This content was generated with the assistance of AI and should be verified against the official documentation before being relied on in production.

A compact reference for GitHub Actions as of 2026-11-10, with actions/checkout v7, actions/setup-node v7, actions/cache v6 and actions/upload-artifact v7. For explanations and complete examples, follow the page links at the end.

Download the GitHub Actions Cheat Sheet (PDF)

Workflow skeleton

name: ci
on:
  push:
    branches: [main]
  pull_request:
  workflow_dispatch:
permissions:
  contents: read
concurrency:
  group: ${{ github.workflow }}-${{ github.ref }}
  cancel-in-progress: true
jobs:
  build:
    runs-on: ubuntu-latest
    timeout-minutes: 15
    steps:
      - uses: actions/checkout@v7
      - run: npm ci && npm test

Triggers

Trigger Notes

push, pull_request

Filter with branches, tags, paths and paths-ignore.

schedule

Cron in UTC, default branch only.

workflow_dispatch

Manual run with typed inputs.

workflow_call

Makes the workflow reusable.

release, workflow_run

Chain on releases or on other workflows.

pull_request_target

Runs with secrets in the base context; never run PR code in it.

Expressions and contexts

Expression Meaning

${{ github.sha }}, ${{ github.ref_name }}

Commit and branch or tag name.

${{ secrets.NAME }}, ${{ vars.NAME }}

Secret and configuration variable.

${{ needs.job.outputs.x }}

Output of a required job.

${{ matrix.os }}

Current matrix value.

${{ hashFiles('**/package-lock.json') }}

Hash of files, used in cache keys.

success(), failure(), always(), cancelled()

Status functions for if:.

Passing data

echo "version=1.2.3" >> "$GITHUB_OUTPUT"      # step output
echo "NAME=value"     >> "$GITHUB_ENV"         # env for later steps
echo "### Done"       >> "$GITHUB_STEP_SUMMARY" # run summary
echo "::add-mask::$TOKEN"                      # mask a value

Runner labels

Label Image

ubuntu-latest, ubuntu-24.04, ubuntu-26.04, ubuntu-24.04-arm

Linux x64 and arm64.

windows-latest, windows-2025, windows-11-arm

Windows.

macos-latest, macos-26, macos-15, macos-26-intel

macOS arm64 and Intel.

[self-hosted, linux, x64]

Your own runner, selected by labels.

Matrix, services, caching

strategy:
  fail-fast: false
  matrix:
    os: [ubuntu-latest, windows-latest]
    node: [22, 24]
steps:
  - uses: actions/setup-node@v7
    with:
      node-version: ${{ matrix.node }}
      cache: npm
  - uses: actions/upload-artifact@v7
    with:
      name: site
      path: build/site
      retention-days: 7

Permissions, OIDC, environments

permissions:
  contents: read
  id-token: write        # request an OIDC token
jobs:
  deploy:
    runs-on: ubuntu-latest
    environment:
      name: production
      url: https://example.com
    steps:
      - run: ./deploy.sh
  call-shared:
    uses: org/repo/.github/workflows/deploy.yml@v1   # reusable workflow
    secrets: inherit

Release publishing

Target Typical step

GitHub release

gh release create v1.2.3 --generate-notes

Maven Central

mvn -B deploy with setup-java server credentials and GPG key

npm

npm publish --provenance --access public

PyPI

pypa/gh-action-pypi-publish@release/v1 with trusted publishing

NuGet

dotnet nuget push with an API key or trusted publishing

GHCR

docker/login-action then docker/build-push-action

GitHub Pages

upload-pages-artifact then deploy-pages

gh commands

gh workflow list
gh workflow run publish.yml -f debug=true
gh run list --workflow publish.yml
gh run watch
gh run view --log-failed
gh run rerun --failed
gh run download -n site
gh secret set NAME
gh variable set NAME --body value
actionlint