Home / Topics / GitHub Actions / Cheatsheet
GitHub Actions

Cheatsheet

Dense reference for daily use and interview prep. GitHub.com Actions in 2025–2026: artifacts v4, `node24` actions, OIDC to AWS/Azure/GCP, ARC runner scale sets, GitHub CLI 2.x.

Contents

Workflow skeleton · Key reference · Triggers · Contexts · Expressions · Workflow commands and files · Matrix · Concurrency · Permissions · Secrets, vars, environments · Reusable workflows vs composite actions · Caching · Artifacts · OIDC AWS · OIDC Azure · OIDC GCP · Hardening · Runners · gh CLI · Debugging · Errors · Top 15


Workflow syntax skeleton

yaml
name: CI                                         # shown in the Actions tab
run-name: CI ${{ github.ref_name }} by @${{ github.actor }}

on:
  push:
    branches: [main]
    tags: ['v*.*.*']
    paths-ignore: ['docs/**', '**.md']
  pull_request:
    branches: [main]
  workflow_dispatch:
    inputs:
      environment:
        type: choice
        options: [dev, staging, prod]
        default: dev
      dry_run:
        type: boolean
        default: true

permissions:
  contents: read                                 # read-only default for every job

concurrency:
  group: ${{ github.workflow }}-${{ github.ref }}
  cancel-in-progress: ${{ github.event_name == 'pull_request' }}

env:
  NODE_VERSION: '22'

defaults:
  run:
    shell: bash                                  # bash --noprofile --norc -eo pipefail {0}

jobs:
  test:
    name: test (node ${{ matrix.node }})
    runs-on: ubuntu-latest
    timeout-minutes: 15
    strategy:
      fail-fast: false
      matrix:
        node: [20, 22, 24]
    steps:
      - uses: actions/checkout@v4
        with:
          persist-credentials: false
      - uses: actions/setup-node@v4
        with:
          node-version: ${{ matrix.node }}
          cache: npm
      - run: npm ci
      - run: npm test

  build:
    needs: test
    if: github.event_name != 'pull_request'
    runs-on: ubuntu-latest
    permissions:
      contents: read
      id-token: write                            # OIDC
    outputs:
      image: ${{ steps.meta.outputs.image }}
    steps:
      - uses: actions/checkout@v4
      - id: meta
        run: echo "image=app:sha-${GITHUB_SHA::7}" >> "$GITHUB_OUTPUT"

  deploy:
    needs: build
    if: github.ref == 'refs/heads/main'
    runs-on: ubuntu-latest
    environment:
      name: prod
      url: https://app.example.com
    concurrency:
      group: deploy-prod
      cancel-in-progress: false
    steps:
      - run: echo "Deploying ${{ needs.build.outputs.image }}"

Workflow keys at a glance

KeyLevelNotes
onworkflowEvents and filters (branches, tags, paths, types)
permissionsworkflow, jobUnlisted scopes become none
envworkflow, job, stepMost specific wins; not usable in jobs.<id>.if (use vars)
defaults.runworkflow, jobshell, working-directory for run steps
concurrencyworkflow, jobOne running + one pending per group
runs-onjobLabel, array of labels, or { group, labels }
needsjobJob dependencies; read needs.<id>.outputs / .result
ifjob, stepImplicit success() && unless a status function is used
strategyjobmatrix, fail-fast (default true), max-parallel
environmentjobProtection rules, env secrets and vars, deployment record
outputsjobMap from step outputs; strings, 1 MB each
container / servicesjobRun steps in a container, sidecars (Linux runners only)
timeout-minutesjob, stepJob default 360
continue-on-errorjob, stepFailure does not fail the job/run
uses (job)jobCall a reusable workflow; no steps/runs-on allowed
uses / runstepAction or shell command
with / id / shell / working-directorystepInputs, reference for outputs, shell, cwd

Triggers

EventTypical useWatch out
pushCI on branches, releases on tagsWorkflow file is read from the pushed commit
pull_requestPR CIRuns on the merge commit; fork PRs get no secrets and a read-only token
pull_request_targetLabel/comment on fork PRsRuns base workflow with secrets and write token: never check out and run PR code
workflow_dispatchManual runs with typed inputsFile must be on the default branch to show in UI
scheduleNightly jobsUTC, default branch only, may be delayed, avoid minute 0, disabled after 60 days inactivity (public repos)
workflow_callReusable workflowInputs, secrets, outputs declared under it
workflow_runPrivileged follow-up after an unprivileged runRuns from default branch with secrets; treat upstream artifacts as untrusted
repository_dispatchExternal systems trigger a runPOST /repos/{o}/{r}/dispatches with event_type and client_payload
merge_groupMerge queue checksRequired checks must also run on merge_group
releasePublish on releaseUse types: [published]
issue_comment, issues, pull_request_reviewChatOps, triageTitles and bodies are attacker-controlled
yaml
on:
  pull_request:
    types: [opened, synchronize, reopened, ready_for_review]   # default: opened, synchronize, reopened
    branches: [main, 'release/**']
    paths: ['src/**', 'package*.json']
  schedule:
    - cron: '17 2 * * 1-5'            # 02:17 UTC, Mon–Fri
  workflow_run:
    workflows: [CI]
    types: [completed]
    branches: [main]
  repository_dispatch:
    types: [deploy-request]
bash
# fire repository_dispatch
gh api repos/OWNER/REPO/dispatches -f event_type=deploy-request -F 'client_payload[env]=staging'

Skip a push/PR run: put [skip ci], [ci skip], [no ci], [skip actions] or [actions skip] in the commit message.


Contexts

ContextCommon fields
githubevent_name, ref, ref_name, ref_type, sha, head_ref, base_ref, repository, repository_owner, actor, triggering_actor, run_id, run_number, run_attempt, workflow, job, server_url, event.*, token
envValues from env: at workflow, job, step level
varsConfiguration variables (org, repo, environment)
secretsSecrets, plus GITHUB_TOKEN
inputsworkflow_dispatch / workflow_call inputs, typed
needsneeds.<job>.result, needs.<job>.outputs.<name>
stepssteps.<id>.outputs.<name>, .outcome, .conclusion
matrix / strategyCurrent leg values; strategy.job-index, strategy.job-total
runneros, arch, name, temp, tool_cache, environment (github-hosted / self-hosted)
jobstatus, container.id, services.<id>.ports

Where contexts are available (common traps):

LocationAllowed contexts
jobs.<id>.ifgithub, needs, vars, inputs (no env, no secrets)
jobs.<id>.runs-on, concurrency, environmentgithub, needs, strategy, matrix, vars, inputs
steps.ifabove plus steps, job, runner, env (no secrets: map to env first)
on.workflow_call.outputs.*.valuejobs

Default environment variables on every runner: GITHUB_SHA, GITHUB_REF, GITHUB_REF_NAME, GITHUB_REPOSITORY, GITHUB_RUN_ID, GITHUB_WORKSPACE, GITHUB_EVENT_PATH, GITHUB_ACTOR, RUNNER_OS, RUNNER_TEMP, CI=true.


Expressions and functions

ExpressionResult
${{ github.ref == 'refs/heads/main' }}String comparisons are case-insensitive
${{ startsWith(github.ref, 'refs/tags/v') }}Tag check
${{ contains(github.event.pull_request.labels.*.name, 'deploy') }}Object filter .* + contains
${{ format('{0}-{1}', runner.os, matrix.node) }}String formatting
${{ join(matrix.*, '-') }}Join array
${{ toJSON(github.event) }}Dump context (great for debugging)
${{ fromJSON(needs.plan.outputs.matrix) }}Parse JSON (dynamic matrix, booleans, numbers)
${{ hashFiles('**/package-lock.json') }}SHA-256 of matching files, empty string if none
${{ inputs.env || 'dev' }}Default value (|| returns first truthy operand)
${{ github.event_name == 'push' && 'prod' || 'dev' }}Ternary idiom (breaks if the middle value is falsy)
success() / failure() / cancelled() / always()Status checks; !cancelled() is the safe "run even on failure"

Falsy values: false, 0, -0, "", null. if: may omit ${{ }}, but an expression that starts with ! must be wrapped or quoted.

yaml
- if: failure() && steps.test.outcome == 'failure'
  run: ./collect-logs.sh
- if: ${{ !cancelled() }}
  uses: actions/upload-artifact@v4
  with: { name: test-results, path: reports/ }

Workflow commands and environment files

PurposeCommand
Step outputecho "version=1.4.0" >> "$GITHUB_OUTPUT"
Env var for later stepsecho "BUILD_DATE=$(date -u +%F)" >> "$GITHUB_ENV"
Add to PATH for later stepsecho "$HOME/.local/bin" >> "$GITHUB_PATH"
Markdown run summaryecho "### Deployed :rocket:" >> "$GITHUB_STEP_SUMMARY"
Multiline value{ echo "notes<<GHA_EOF"; cat notes.md; echo "GHA_EOF"; } >> "$GITHUB_OUTPUT"
Mask a runtime valueecho "::add-mask::$TOKEN"
Fold log linesecho "::group::Install" … echo "::endgroup::"
Annotationsecho "::error file=app.js,line=10,col=5,title=Lint::Unexpected var" (::warning, ::notice)
Debug line (shown with debug on)echo "::debug::cache key is $KEY"
Stop processing commandsecho "::stop-commands::$(uuidgen)" … echo "::<same-token>::"

::set-output and ::set-env are deprecated/disabled: use the environment files.


Matrix

yaml
strategy:
  fail-fast: false
  max-parallel: 4
  matrix:
    os: [ubuntu-latest, windows-latest, macos-latest]
    node: [20, 22, 24]
    exclude:
      - os: macos-latest
        node: 20
    include:
      - os: ubuntu-latest           # adds a key to an existing leg
        node: 24
        coverage: true
      - os: ubuntu-24.04-arm        # adds a brand new leg
        node: 24
continue-on-error: ${{ matrix.experimental == true }}

Dynamic matrix from a previous job:

yaml
jobs:
  plan:
    runs-on: ubuntu-latest
    outputs:
      services: ${{ steps.s.outputs.services }}
    steps:
      - id: s
        run: echo 'services=["api","web"]' >> "$GITHUB_OUTPUT"
  build:
    needs: plan
    if: needs.plan.outputs.services != '[]'
    strategy:
      matrix:
        service: ${{ fromJSON(needs.plan.outputs.services) }}
    runs-on: ubuntu-latest
    steps:
      - run: echo "building ${{ matrix.service }}"

Limits: 256 jobs per matrix per run. Fan-in gate for branch protection:

yaml
ci-ok:
  needs: [lint, test, build]
  if: always()
  runs-on: ubuntu-latest
  steps:
    - env:
        NEEDS: ${{ toJSON(needs) }}
      run: echo "$NEEDS" | jq -e 'all(.[]; .result == "success" or .result == "skipped")'

Concurrency

GoalConfig
Cancel superseded PR runsgroup: ${{ github.workflow }}-${{ github.ref }}, cancel-in-progress: true
Cancel on PRs only, never on maincancel-in-progress: ${{ github.event_name == 'pull_request' }}
Unique group per main pushgroup: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
Serialize deploys per environmentJob-level group: deploy-${{ inputs.environment }}, cancel-in-progress: false
Cross-repo lockSame literal group name is not shared across repos; use an external lock or one deploy repo

Rule: per group, one running and at most one pending. A newer pending run replaces the older pending one (it is cancelled).


Permissions

yaml
permissions:                 # workflow default
  contents: read
jobs:
  release:
    permissions:             # job override replaces, does not merge
      contents: write        # create release, push tags
      id-token: write        # OIDC
      packages: write        # GHCR
      attestations: write    # artifact attestations
      pull-requests: write   # PR comments
ScopeNeeded for
contentscheckout (read), push, tags, releases (write)
pull-requestscomment, label, review on PRs
issuescreate/comment issues
packagespush to GHCR
id-tokenrequest OIDC JWT (write)
actionscancel runs, delete caches
checks / statusescreate check runs or commit statuses
security-eventsupload SARIF to code scanning
deploymentscreate deployment records
attestationsactions/attest-build-provenance

Shortcuts: permissions: {} (nothing), read-all, write-all (avoid). Fork PRs always get a read-only token. Events created by GITHUB_TOKEN do not trigger new runs (except workflow_dispatch, repository_dispatch); use a GitHub App token when they must.


Secrets, variables and environments

TaskCommand
Repo secretgh secret set API_TOKEN --body "$VALUE"
Secret from filegh secret set KUBECONFIG_B64 < kubeconfig.b64
Environment secretgh secret set DB_PASSWORD --env prod --body "$VALUE"
Org secret for selected reposgh secret set NPM_TOKEN --org ORG --repos "api,web"
Variablegh variable set AWS_REGION --body ap-south-1 (--env prod for environment)
Listgh secret list --env prod, gh variable list
Create environmentgh api -X PUT repos/OWNER/REPO/environments/prod
Add wait timergh api -X PUT repos/OWNER/REPO/environments/staging -F wait_timer=10

Precedence: environment > repository > organization. Secrets: 48 KB max each, masked in logs, not passed to fork PRs, cannot be used directly in if:. Environment protection: required reviewers (up to 6), prevent self-review, wait timer (up to 43,200 minutes), deployment branch and tag policies, custom protection rules.


Reusable workflows vs composite actions

Reusable workflowComposite action
Defined byon: workflow_call in .github/workflows/*.ymlaction.yml with runs.using: composite
Called atJob level: jobs.x.uses:Step level: steps[*].uses:
Unit of reuseOne or more whole jobsA sequence of steps inside the caller's job
Own runner, environment, permissionsYesNo (shares caller's runner, workspace, env)
Secretssecrets: mapping or secrets: inheritOnly via inputs
LogsEach job and step shown separatelyCollapsed under one step
InputsTyped (string, boolean, number)Always strings
Limits10 nested levels, 50 unique workflows per runComposite can nest other actions
Use forStandard pipelines, deploy with approvalsShared setup, small building blocks
yaml
# .github/workflows/deploy.yml (callee)
on:
  workflow_call:
    inputs:
      environment: { type: string, required: true }
      image:       { type: string, required: true }
    secrets:
      SLACK_WEBHOOK: { required: false }
    outputs:
      url:
        value: ${{ jobs.deploy.outputs.url }}
jobs:
  deploy:
    runs-on: ubuntu-latest
    environment: ${{ inputs.environment }}
    permissions: { contents: read, id-token: write }
    outputs:
      url: ${{ steps.out.outputs.url }}
    steps:
      - id: out
        run: echo "url=https://${{ inputs.environment }}.example.com" >> "$GITHUB_OUTPUT"
yaml
# caller
jobs:
  deploy-dev:
    uses: ./.github/workflows/deploy.yml              # or ORG/platform/.github/workflows/deploy.yml@<sha>
    permissions: { contents: read, id-token: write }  # callee can only reduce these
    with:
      environment: dev
      image: ${{ needs.build.outputs.image }}
    secrets: inherit
yaml
# .github/actions/setup-app/action.yml (composite)
name: setup-app
inputs:
  node-version: { default: '22' }
outputs:
  cache-hit: { value: '${{ steps.node.outputs.cache-hit }}' }
runs:
  using: composite
  steps:
    - id: node
      uses: actions/setup-node@v4
      with: { node-version: '${{ inputs.node-version }}', cache: npm }
    - run: npm ci
      shell: bash                                      # required in composite run steps

Other action types: JavaScript (runs.using: node24, main: dist/index.js, bundle with ncc) and Docker (runs.using: docker, image: Dockerfile, Linux runners only).


Caching

yaml
- uses: actions/cache@v4
  id: cache
  with:
    path: |
      ~/.cache/pip
      ~/.cache/pre-commit
    key: ${{ runner.os }}-py-${{ hashFiles('**/requirements*.txt', '.pre-commit-config.yaml') }}
    restore-keys: |
      ${{ runner.os }}-py-
- if: steps.cache.outputs.cache-hit != 'true'
  run: pip install -r requirements.txt
ToolBuilt-in cache
Nodeactions/setup-node cache: npm | yarn | pnpm
Pythonactions/setup-python cache: pip | pipenv | poetry
Goactions/setup-go (on by default, keyed on go.sum)
Javaactions/setup-java cache: maven | gradle | sbt
Dockercache-from: type=gha / cache-to: type=gha,mode=max in docker/build-push-action
RuleDetail
SaveOnly when the exact key missed, at end of a successful job (actions/cache/save to control it)
ScopeCurrent branch, then PR base branch, then default branch; PR caches invisible to main
Quota10 GB per repo by default, LRU eviction, 7 days unused = evicted
ImmutableA key cannot be overwritten; bump the key (e.g. -v2-) to force refresh
Managegh cache list, gh cache delete <key|id>, gh cache delete --all

Artifacts

yaml
- uses: actions/upload-artifact@v4
  with:
    name: report-${{ matrix.node }}       # names must be unique per run
    path: |
      reports/
      !reports/**/*.tmp
    retention-days: 7
    if-no-files-found: error
- uses: actions/download-artifact@v4
  with:
    pattern: report-*
    merge-multiple: true
    path: all-reports
FactDetail
PurposeOutputs of a run (binaries, reports, SBOMs), not dependency caches
v4 semanticsImmutable, available immediately after upload, unique names, no mixing with v3
RetentionDefault 90 days (configurable per repo/org, retention-days per upload)
Cross-run downloadactions/download-artifact@v4 with run-id and github-token
CLIgh run download <run-id> -n report-22

OIDC to AWS

yaml
permissions:
  id-token: write
  contents: read
steps:
  - uses: aws-actions/configure-aws-credentials@v4
    with:
      role-to-assume: arn:aws:iam::123456789012:role/gha-deploy-prod
      aws-region: ap-south-1
      role-session-name: gha-${{ github.run_id }}
  - run: aws sts get-caller-identity
  - uses: aws-actions/amazon-ecr-login@v2
bash
aws iam create-open-id-connect-provider \
  --url https://token.actions.githubusercontent.com \
  --client-id-list sts.amazonaws.com
json
{
  "Version": "2012-10-17",
  "Statement": [{
    "Effect": "Allow",
    "Principal": { "Federated": "arn:aws:iam::123456789012:oidc-provider/token.actions.githubusercontent.com" },
    "Action": "sts:AssumeRoleWithWebIdentity",
    "Condition": {
      "StringEquals": {
        "token.actions.githubusercontent.com:aud": "sts.amazonaws.com",
        "token.actions.githubusercontent.com:sub": "repo:ORG/REPO:environment:prod"
      }
    }
  }]
}
Job contextsub claim
Branch push / dispatchrepo:ORG/REPO:ref:refs/heads/main
Tagrepo:ORG/REPO:ref:refs/tags/v1.2.0 (use StringLike with refs/tags/v*)
Pull requestrepo:ORG/REPO:pull_request
Job with environmentrepo:ORG/REPO:environment:prod
Custom templatee.g. repo:ORG/REPO:environment:prod:job_workflow_ref:ORG/platform/.github/workflows/deploy.yml@refs/heads/main

Never trust only aud, and never repo:ORG/* for a prod role.


OIDC to Azure

bash
az ad app federated-credential create --id <APP_OBJECT_ID> --parameters '{
  "name": "gha-prod",
  "issuer": "https://token.actions.githubusercontent.com",
  "subject": "repo:ORG/REPO:environment:prod",
  "audiences": ["api://AzureADTokenExchange"]
}'
az role assignment create --assignee <CLIENT_ID> --role Contributor \
  --scope /subscriptions/<SUB_ID>/resourceGroups/rg-app-prod
yaml
permissions:
  id-token: write
  contents: read
jobs:
  deploy:
    environment: prod
    runs-on: ubuntu-latest
    steps:
      - uses: azure/login@v2
        with:
          client-id: ${{ vars.AZURE_CLIENT_ID }}
          tenant-id: ${{ vars.AZURE_TENANT_ID }}
          subscription-id: ${{ vars.AZURE_SUBSCRIPTION_ID }}
      - run: az group show -n rg-app-prod -o table

Azure matches subject exactly (one federated credential per branch/environment; up to 20 per identity). IDs are not secrets, so vars is fine.


OIDC to GCP

bash
gcloud iam workload-identity-pools create github --location=global
gcloud iam workload-identity-pools providers create-oidc gha --location=global \
  --workload-identity-pool=github \
  --issuer-uri=https://token.actions.githubusercontent.com \
  --attribute-mapping="google.subject=assertion.sub,attribute.repository=assertion.repository" \
  --attribute-condition="assertion.repository_owner == 'ORG'"
gcloud iam service-accounts add-iam-policy-binding [email protected] \
  --role=roles/iam.workloadIdentityUser \
  --member="principalSet://iam.googleapis.com/projects/PROJECT_NUMBER/locations/global/workloadIdentityPools/github/attribute.repository/ORG/REPO"
yaml
- uses: google-github-actions/auth@v2
  with:
    workload_identity_provider: projects/PROJECT_NUMBER/locations/global/workloadIdentityPools/github/providers/gha
    service_account: [email protected]

Security hardening

ControlHow
Least-privilege tokenRepo default "read", permissions: contents: read at top, grant per job
Pin third-party actionsuses: owner/action@<40-char-sha> # v1.2.3; Dependabot package-ecosystem: github-actions
Restrict actionsOrg/repo setting: GitHub-owned + verified + allow-list; optionally require SHA pinning
No script injectionPass github.event.* (titles, bodies, branch names) via env: and quote "$VAR"
No pwn requestsNever check out PR head in pull_request_target; split into pull_request + workflow_run
Don't leave the token on diskactions/checkout with persist-credentials: false
Keyless cloud accessOIDC with tight sub; per-environment roles
Gate secretsEnvironment secrets + required reviewers + branch/tag policies
Protect workflow filesCODEOWNERS on .github/, rulesets requiring code-owner review
Self-hosted runnersEphemeral/JIT only, never on public repos, runner groups restricted to repos
Fork PRs"Require approval for first-time / all outside collaborators"
Provenanceactions/attest-build-provenance, verify with gh attestation verify
Lint and auditactionlint, zizmor .github/workflows in CI
yaml
# injection-safe
- env:
    TITLE: ${{ github.event.pull_request.title }}
  run: echo "PR title: $TITLE"

Runners

RunnerLabel examplesNotes
Hosted Linuxubuntu-latest, ubuntu-24.04, ubuntu-22.041x minute multiplier, fresh VM per job
Hosted Linux arm64ubuntu-24.04-armFree for public repos
Hosted Windows / macOSwindows-latest, macos-latest, macos-152x / 10x multipliers in private repos
Larger runnersCustom names, runs-on: { group: big, labels: ubuntu-16core }Paid, static IPs, more CPU/RAM
Self-hosted[self-hosted, linux, x64, gpu]All labels must match
ARC scale setruns-on: arc-linux (Helm release name)Ephemeral pods, minRunners/maxRunners
bash
# self-hosted (ephemeral)
./config.sh --url https://github.com/ORG/REPO --token <REG_TOKEN> --labels gpu --ephemeral --unattended
gh api -X POST repos/ORG/REPO/actions/runners/registration-token --jq .token

# ARC
helm install arc -n arc-systems --create-namespace \
  oci://ghcr.io/actions/actions-runner-controller-charts/gha-runner-scale-set-controller
helm install arc-linux -n arc-runners --create-namespace \
  --set githubConfigUrl=https://github.com/ORG --set githubConfigSecret=arc-github-app \
  --set minRunners=0 --set maxRunners=20 \
  oci://ghcr.io/actions/actions-runner-controller-charts/gha-runner-scale-set

gh CLI

TaskCommand
List workflowsgh workflow list
Show a workflow's recent runsgh workflow view ci.yml
Trigger dispatchgh workflow run deploy.yml --ref main -f environment=staging -f dry_run=false
Inputs from JSONecho '{"environment":"prod"}' | gh workflow run deploy.yml --json
Enable / disablegh workflow enable ci.yml, gh workflow disable ci.yml
List runsgh run list -w ci.yml -b main -L 20 (--status failure, -e pull_request)
Watch livegh run watch <id> --exit-status
View summary / jobsgh run view <id>, gh run view <id> --verbose
Failed logs onlygh run view <id> --log-failed
Full log of one jobgh run view --job <job-id> --log
Re-rungh run rerun <id> / --failed / --job <job-id> / --debug
Cancelgh run cancel <id>
Delete a rungh run delete <id>
Download artifactsgh run download <id> / -n name / -p 'report-*'
Cachesgh cache list --sort size_in_bytes, gh cache delete --all
Secrets / variablesgh secret set NAME --env prod, gh variable list
Verify attestationgh attestation verify oci://ghcr.io/org/app@sha256:... --owner org
Raw APIgh api repos/ORG/REPO/actions/runs --jq '.workflow_runs[0].status'
Local extensiongh extension install nektos/gh-act then gh act -l
bash
# latest run on this branch, wait for it, fail the shell if it fails
gh run watch "$(gh run list -b "$(git branch --show-current)" -L1 --json databaseId --jq '.[0].databaseId')" --exit-status

# cancel all in-progress runs of a workflow
gh run list -w ci.yml -s in_progress --json databaseId --jq '.[].databaseId' | xargs -n1 gh run cancel

# conclusions of every job in a run
gh run view <id> --json jobs --jq '.jobs[] | "\(.name)\t\(.conclusion)"'

Debugging

NeedHow
Verbose step logsRe-run with "Enable debug logging", gh run rerun <id> --debug, or set secret/variable ACTIONS_STEP_DEBUG=true
Runner diagnostic logsACTIONS_RUNNER_DEBUG=true (adds runner/worker logs to the log archive)
See the event payload- run: cat "$GITHUB_EVENT_PATH" | jq . or echo '${{ toJSON(github) }}' via env
Why a step was skippedDebug logs show Evaluating condition for step with the expanded expression
Workflow never startedFile on wrong branch, filters (branches AND paths), YAML error (red banner in Actions tab), disabled workflow, [skip ci], created by GITHUB_TOKEN
Stuck "Waiting for a runner"Label mismatch, runner group not allowed for repo, concurrency limit reached, ARC listener down
Lint before pushingactionlint, zizmor .github/workflows
Run locallyact -j test (nektos/act, approximation of hosted runners)
Interactive shellmxschmitt/action-tmate (avoid on public repos; set limit-access-to-actor: true)

Common errors

ErrorFix
Resource not accessible by integrationAdd the missing permissions scope; fork PRs are read-only
Not authorized to perform sts:AssumeRoleWithWebIdentityTrust policy sub does not match (environment vs ref form, casing, tag vs branch)
Unable to get ACTIONS_ID_TOKEN_REQUEST_URL env variableMissing id-token: write (on the calling job for reusable workflows)
AADSTS700213: No matching federated identity record foundAzure federated credential subject does not match the token's sub
Dependencies lock file is not foundCommit the lockfile or drop cache: in setup-*; check cache-dependency-path
Matrix vector 'x' does not contain any valuesDynamic matrix got []; guard the job with if
Conflict: an artifact with this name already exists on the workflow runUnique artifact names per matrix leg, or overwrite: true
The workflow is not valid. ... Unexpected value 'x'YAML key typo/indentation; run actionlint
Branch "x" is not allowed to deploy to prod due to environment protection rulesAdd the branch/tag to the environment's deployment policy
Skip output 'x' since it may contain secretJob outputs containing secrets are dropped; pass a reference, not the secret
This request was automatically failed because there were no enabled runners onlineNo matching self-hosted runner, or runner group excludes the repo
Error: Process completed with exit code 1.Read the lines above it; add set -x; check the step's shell
Required check stuck "Expected — Waiting for status to be reported"Workflow skipped by path filter or renamed job; use an always-running gate job
refusing to allow a GitHub App to create or update workflow ... without workflows permissionToken needs workflows scope (PAT) or workflows: write (App) to push .github/workflows changes

Top 15 interview one-liners

  1. Workflow, job, step, action, runner: an event starts a workflow run; jobs run in parallel on separate runners unless needs orders them; steps run sequentially in one job and share the workspace; an action is a reusable step.
  2. pull_request vs pull_request_target: pull_request runs the PR's code without secrets for forks; pull_request_target runs the base branch's workflow with secrets and a write token, so it must never execute PR code.
  3. GITHUB_TOKEN: a per-job installation token that expires with the job, scoped by permissions; set contents: read by default and grant per job.
  4. Why a tag pushed by the workflow didn't trigger release: events from GITHUB_TOKEN don't start new runs (loop prevention); use a GitHub App token.
  5. OIDC: the job requests a signed JWT (id-token: write), the cloud validates issuer, audience and sub, and returns credentials for about an hour; no static keys in GitHub.
  6. The sub claim: repo:ORG/REPO:ref:refs/heads/main, ...:environment:prod or ...:pull_request; the trust policy must pin it, never only aud.
  7. Script injection: ${{ }} is substituted into the script before the shell runs, so untrusted event data in run: is code execution; pass it via env:.
  8. Pin actions by SHA: tags are mutable (tj-actions/changed-files, March 2025, showed it); a full commit SHA is immutable, and Dependabot keeps pins current.
  9. Cache vs artifact: cache speeds up future runs (keyed, evictable, best effort); artifacts store a run's outputs (immutable in v4, 90-day default retention).
  10. Reusable workflow vs composite action: reusable workflows share whole jobs with their own runners, environments and secrets; composite actions share steps inside the caller's job.
  11. Concurrency: one running and one pending per group; cancel-in-progress for PRs, queue (no cancel) for deployments.
  12. Required checks with a matrix: make a single if: always() gate job the required check, because skipped jobs count as passing and matrix names change.
  13. Environments: they gate a job with reviewers, wait timers and branch policies, release environment secrets only after approval, and change the OIDC sub.
  14. Self-hosted runners: treat them as untrusted, make them ephemeral (ARC scale sets or --ephemeral/JIT), restrict with runner groups, and never attach them to public repos.
  15. Debugging: gh run view --log-failed, re-run with debug logging (ACTIONS_STEP_DEBUG), dump toJSON(github) through env, and lint with actionlint before pushing.

Feedback