GitHub Hour 5: Production-Grade Actions: Reuse, Releases, and Hardening

From a “workflow that runs” to a delivery pipeline that is shared across the organization, traceable, verifiable, and hard to compromise
actions/checkout v7.0.1actions/attest v4.2.2docker/build-push-action v7.4.0gh 2.104.0Verified against docs.github.com · 2026-11-15
Overall learning goals
  • Use reusable workflows (on: workflow_call) to turn build, release, and deploy into organization-level “pipeline templates”, explain how inputs / secrets / outputs flow,secrets: inherit the boundaries and limits of 10 levels of nesting and 50 distinct reusable workflows ; choose between reusable workflows and composite actions.
  • Write JavaScript (node24) / Docker / composite three kinds of custom actions. You will learn to use @actions/core ncc to package them, understand how to publish to Marketplace, and understand immutable releases (2025-10 GA) and their impact on the traditional practice of “moving the v1 tag”.
  • Automate releases: automatically generate release notes,gh release create upload assets, and publish drafts before publishing; connect with the release-please / semantic-release tools from the Git course.
  • Push images to GHCR: packages: write, link packages and repositories, inherit permissions, multi-architecture images, and clean up old versions.
  • Use artifact attestations to generate SLSA build provenance and SBOM attestations for binaries and images, and use gh attestation verify to verify; understand how it relates to Sigstore / cosign, and “reusable workflow build → SLSA Build L3”.
  • System hardening: least-privilege permissions, SHA pinning, or workflow dependency lock files, Dependabot, script injection protection,pull_request_target risks (checkout v7 protections and the default event policy from 2026-12-02), zizmor / OpenSSF Scorecard audits, and a review of the tj-actions/changed-files incident.
  • Organization governance: allowed actions list and SHA pinning policy, default GITHUB_TOKEN permissions, the rule “require workflow to pass” in rulesets, Actions policies (workflow execution protection), organization secrets access scope, and runner groups.

1-hour time allocation table

#TimeModuleCore contentAnimation / interactionLab (myorg-lab organization)
0Before classPreparation: organization and shared repositoryFree organization myorg-lab, move myapp into the organization, create a platform-workflows shared repository, gh login and permission check8-item “production-grade Actions” self-assessmentTwo public repositories ready
100–08Reusable workflows and composite actionsworkflow_call inputs/secrets/outputs,secrets: inherit, permissions can only be lowered, not raised, 10-level / 50-workflow limits, composite actions, and choosing between themCore animation: call chain and permission intersectionExtract an organization-shared build-test workflow
208–15Writing custom actionsaction.yml, JS action (@actions/core, ncc, node24), Docker action, composite,$/ self-reference, Marketplace, version tags, and immutable releasesComparison of the three action execution pathsWrite a setup-myapp composite action + one JS action
315–22Release automationReleases and tags, automatically generated release notes,.github/release.yml,gh release create, assets, draft → publish, immutable releases, release attestationsRelease pipeline timelinePush a tag to trigger a Release and upload assets
422–29GitHub Packages and GHCRGHCR authentication,packages: write, package linking and permission inheritance, visibility, multi-architecture images, cleaning up old versionsMulti-architecture manifest list builderPush amd64+arm64 images
529–37Artifact attestations and the supply chainactions/attest (provenance / SBOM), OIDC → Fulcio → Rekor,gh attestation verify, SLSA Build L2/L3, cosign/NotationCore animation: attestation generation and verificationGenerate and verify attestations for an image
637–46Actions security hardeningSHA pinning / lock files / Dependabot, permissions, pull_request_target and workflow_run, script injection, zizmor, Scorecard, tj-actions reviewScript injection attack and defense simulatorScan and fix with zizmor
746–54Organization governanceallowed actions, SHA pinning policy, default GITHUB_TOKEN permissions, ruleset requiring workflows, Actions policies, organization secrets, runner groupsPolicy layering calculatorConfigure the governance baseline for myorg-lab
854–60Recap, self-check, and cleanup for the first five hoursConnecting the five lessons, common troubleshooting decision tree, cleanupInteractive troubleshooting treeClean up packages, tokens, and test repositories
—After classCheat sheet · Integrated labRefactor myapp CI/CD into “organization-shared reusable workflows + composite actions + GHCR multi-architecture + attestations + auditing”Final quiz (12 questions)Integrated lab

Knowledge Coverage Matrix

Target skillM1M2M3M4M5M6M7M8Key commands / keywordsLab
Write and call reusable workflows✓···✓·✓✓workflow_call,secrets: inheritM1 / integrated
Write custom actions✓✓···✓··action.yml,ncc buildM2
Release and asset automation·✓✓·✓···gh release create --generate-notesM3
GHCR push and permissions···✓✓·✓✓packages: write,docker buildxM4
Generate and verify build attestations✓·✓✓✓··✓actions/attest,gh attestation verifyM5
Dependency pinning and updates·✓···✓✓·SHA pinning,gh actions-lock, DependabotM6
Identify and fix workflow vulnerabilities·····✓✓✓zizmor, ScorecardM6
Organization-level Actions governance✓··✓·✓✓·allowed actions, rulesets, Actions policiesM7
Troubleshooting and cleanup✓··✓✓·✓✓gh run view --log-failedM8

Topics not covered in this lesson (and where to learn them)

TopicWhy it is not in this lessonWhere to learn
Signed commits and tags (GPG/SSH/gitsign), conventional commits, and configuration details for release-please / semantic-releaseAlready covered in full in the Git courseGit Hour 5(module 4 signing, module 6 conventional commits and automated releases)
Workflow syntax, triggers, matrix, caching, artifacts, environments and approvalsAssumed as already mastered in this lessonGitHub Hour 2
OIDC login to Azure / AWS, federated credentials, and immutable subjectsBelongs to cloud platform topicsHour 3 (Azure) · Hour 4 (AWS)
GHAS: code scanning, secret scanning and push protection, dependency review, security configurationBelongs to enterprise security topicsHour 6
ARC self-hosted runners, larger runners, API rate limits, performance tuningBelongs to advanced operations topicsHour 7
Writing Dockerfiles, BuildKit caching, image slimmingBelongs to container topicsDocker 8-hour course

How to use this courseware

10 pages per module
Theory · diagrams · animation · commands · labs · production cases · troubleshooting · quizzes · voice · video. Read “Theory” and “Animation” first, then do the “Lab”.
Learning progress
A quiz score of 70% or more, or clicking “Mark this module complete”, counts toward progress. It is saved in this browser (cleared on refresh if local storage is disabled).
Chinese voice
The “Voice” page uses the browser Web Speech API (en-US) to read the narration script aloud; without a Chinese voice pack, you can read the narration script directly.
Version notes All version numbers in this lesson were checked on 2026-11-15 via the GitHub API and docs.github.com: actions/checkout v7.0.1,actions/attest v4.2.2 (attest-build-provenance v4 onward is only its wrapper,attest-sbom which is being deprecated),docker/build-push-action v7.4.0,docker/setup-buildx-action v4.4.1,docker/setup-qemu-action v4.4.0,docker/login-action v4.8.0,docker/metadata-action v6.2.0,@actions/core 3.0.1,@vercel/ncc 0.45.0, zizmor v1.32.0,ossf/scorecard-action v2.5.0, gh 2.104.0, cosign v3.1.4. The SHAs in the examples were looked up git ls-remote on the verification date; re-check them before you use them. GitHub platform features change quickly, so follow the official documentation for UI paths and plan limits.

Module 0 · Preparation: organization and shared repository (complete before class)

This lesson is the first to truly use “organizations”: sharing reusable workflows, organization secrets, and the allowed actions list are all scoped to the organization
Before class ≈ 10 minA GitHub Free organization is enoughCost: 0 (all public repositories are used)
Prerequisites
  • CompletedHour 2: the myapp repository under your personal account (Flask + gunicorn + Redis, including Dockerfile,/healthz,tests/) and .github/workflows/ci.yml.
  • Local machine: gh ≥ 2.104, Git 2.56, Docker Engine 29 (with buildx), Node.js 24 (for the module 2 JS action), Python 3.12+ or uv (for zizmor in module 6).
  • Why use public repositories: under GitHub Free / Team plans, artifact attestations can only be used with public repositories (private and internal repositories require GitHub Enterprise Cloud); private repositories in a Free organization also cannot read organization-level secrets/variables. Public repositories let every lab in this course be completed at zero cost.

Step 1: check gh login and token scopes

gh --version
gh auth status
# This lesson needs workflow (to edit .github/workflows), read:org / admin:org (organization settings), write:packages / delete:packages (GHCR)
gh auth refresh -h github.com -s workflow,admin:org,write:packages,delete:packages
gh version 2.104.0 (2026-11-12)
github.com
  ✓ Logged in to github.com account YOUR-USER (keyring)
  - Active account: true
  - Git operations protocol: https
  - Token: gho_************************************
  - Token scopes: 'admin:org', 'delete:packages', 'gist', 'read:org', 'repo', 'workflow', 'write:packages'
Note The gh OAuth token is a kind of “classic” scoped token. GHCR currently accepts only personal access token (classic) or the GITHUB_TOKEN, not fine-grained PATs. To push images locally, the gh token is enough; after the course ends, revoke extra scopes in module 8 .

Step 2: create the free organization myorg-lab

Organizations can only be created on the web: top-right avatar → Your organizations → New organization → choose Free, and enter the name myorg-lab (names are globally unique; if it is taken, pick another, for example myorg-lab-yourname; replace it consistently in the rest of the lesson).

export ORG=myorg-lab            # replace with your organization name
gh api orgs/$ORG --jq '{login, plan: .plan.name, default_repository_permission}'
{"default_repository_permission":"read","login":"myorg-lab","plan":"free"}

Step 3: move myapp into the organization and create the shared repository

cd ~/src/myapp
# Option A (recommended, keeps the personal repository): create a public repository under the organization and push
gh repo create $ORG/myapp --public --source=. --remote=org --push

# Organization shared repository: holds reusable workflows and composite actions
gh repo create $ORG/platform-workflows --public --clone --description "Shared reusable workflows and actions"
gh repo list $ORG
✓ Created repository myorg-lab/myapp on github.com
✓ Added remote https://github.com/myorg-lab/myapp.git
✓ Pushed commits to https://github.com/myorg-lab/myapp.git
✓ Created repository myorg-lab/platform-workflows on github.com
Showing 2 of 2 repositories in @myorg-lab
myorg-lab/platform-workflows  Shared reusable workflows and actions  public  now
myorg-lab/myapp                                                     public  now
Why create platform-workflows separately Reusable workflows must be placed in the repository's .github/workflows/ directory (they cannot be in subdirectories). Keeping them in one repository maintained by the platform team and protected by rulesets lets you apply version tags consistently, and application repositories reference them by tag or SHA. This is exactly the “trusted build definition” that “SLSA Build L3” in module 5 requires.

Step 4: confirm the organization Actions settings allow this lesson's labs

gh api orgs/$ORG/actions/permissions
gh api orgs/$ORG/actions/permissions/workflow
{"enabled_repositories":"all","allowed_actions":"all","sha_pinning_required":false}
{"default_workflow_permissions":"read","can_approve_pull_request_reviews":false}

New organizations default to GITHUB_TOKEN read-only (read) and do not allow workflows to create or approve PRs. This is a good thing: every workflow in this lesson declares the permissions it needs explicitly at the job level permissions. Field names follow the current response of the REST API: Actions permissions endpoint.

Warm-up: answer from memory (30 seconds)

At the job level permissions If you write contents: read, what are the other permissions?

Any permission not listed is none (metadata always readable). So once you write permissions, list everything you need, for example pushing images requires packages: write, and generating attestations requires id-token: write + attestations: write.

GITHUB_TOKEN Can it still be used after a run finishes?

No. It is issued when the job starts, expires after the job ends (at most 24 hours later), and its permissions only apply to the current repository. This is the fundamental reason it is safer than a PAT, and why module 4 recommends it for pushing to GHCR.

“Production-grade Actions” self-assessment (8 items)

Check the items your myapp currently meets (saved in this browser). Check again after you finish the integrated lab.

Environment self-check list

Module 1 · Reusable workflows and composite actions

00:00 – 08:00 · Reusable workflows reuse a “whole set of jobs”, while composite actions reuse a “sequence of steps”. Their boundaries differ, and permissions, secrets, and log behavior are completely different too
8 minNesting up to 10 levels · 50 distinct workflowssecrets are passed only to direct callees★★★★★
Learning goals
  • Write a reusable workflow that uses inputs,secrets,outputs and workflow_call and call it from another repository by tag or SHA.
  • Explain secrets: inherit the boundaries (same organization/enterprise, only to direct callees),env does not propagate across calls,GITHUB_TOKEN and permissions can only be kept or lowered.
  • Remember the official limits: at most 10 levels of nesting, and a single workflow file can call at most 50 distinct reusable workflows (including the entire nested tree).
  • Write a composite action (runs.using: composite), and choose between the two depending on the scenario.
Prerequisites: Hour 2's job / step / outputs / needs. Importance:★★★★★ (foundation of platform engineering)

What: two units of reuse

  • Reusable workflow: an ordinary workflow file whose trigger includes on: workflow_call. The caller uses at the job level Use jobs.<id>.uses: OWNER/REPO/.github/workflows/FILE.yml@REF to call; all jobs in the called file will run in this run of the caller, each taking a runner, and appear in the run graph as an expandable group.
  • Composite action (composite action): a directory containing action.yml,runs.using: composite, with several steps. The caller uses at the step level to call uses: OWNER/REPO/PATH@REF , all steps run on the same runner as the caller's current job and logs are collapsed into one step.

Why: why reuse

An organization with dozens or hundreds of repositories, each copy-pasting CI YAML, ends up with version drift (some still use old node16 actions), security fixes that must be made a hundred times, and audits with no clear starting point. Reusable workflows let the platform team maintain “one trusted pipeline definition” while application teams only pass parameters. Composite actions turn repeated step fragments (installing toolchains, logging in, caching) into a versioned building block.

How: how data flows through the call chain

ChannelDeclared by the called sidePassed in by the callerKey rules (docs.github.com, verified 2026-11)
inputson.workflow_call.inputs.<id>: type (boolean / number / string),required,defaultwith:in the called workflow, use ${{ inputs.id }} to read; type mismatches error at startup
secretson.workflow_call.secrets.<id> (can required: true)secrets: { NAME: ${{ secrets.X }} } or secrets: inheritinherit only applies to calls within the same organization or enterprise; secrets are passed only to the directly called workflow, so in A→B→C, for C to get A's secret, A must pass it to B, and B must explicitly pass it on to C
outputson.workflow_call.outputs.<id>.value: ${{ jobs.J.outputs.K }}${{ needs.CALLER_JOB.outputs.id }}step output → job output → workflow output: all three mapping layers are required; for matrix calls, the value taken is from the last run that completed successfully and actually set a value
env——Caller workflow level env does not pass to the called workflow, and vice versa; share values at the organization/repository level vars or inputs
GITHUB_TOKEN permissionsof the called job permissionsof the calling job permissionscan only stay the same or be reduced, and cannot be raised; if the calling job does not write permissions, the called workflow gets GITHUB_TOKEN the default permissions
github context——is always the caller's event context; github.workflow is the caller's name (concurrency group name collisions!)

Keywords the calling job can use

A job that calls a reusable workflow can only write: name,uses,with,secrets (including inherit),strategy,needs,if,concurrency,permissions,cache-mode. Cannot write runs-on,steps,environment,env,timeout-minutes—these are all declared by the called job itself. When an environment secret is needed, on the called side's job, write environment, and the caller must still pass (or inherit) that secret.

Official limits (verified 2026-11)

  • Maximum chain of 10 levels of workflows (top-level caller + 9 nested levels). Earlier docs and blogs said 4 levels and 20 workflows; those are outdated.
  • A single workflow file can call at most 50 distinct reusable workflows,including the entire nested tree (caller → w1 → w2 counts as 2).
  • No redirects: after the called repository is renamed or transferred, old references fail outright.
  • Access rules: callers in public repositories can only call reusable workflows in public repositories; callers in private repositories can call public or authorized private repositories (set in the called repository's Settings → Actions → General → Access).
  • Runners and billing: GitHub-hosted runners are always allocated and billed according to the caller context; called workflows in the same organization can use self-hosted runners that the caller can access.
  • Re-runs: when the reference is not a SHA, “re-run all jobs” re-resolves the reference; “re-run failed jobs” uses the same SHA as the first run.

Composite action key points

  • Each run step must write shell:; inside a step you can uses: use other actions (including other composite actions).
  • No separate secrets channel: secrets must be passed in via inputs inputs (the caller writes with: token: ${{ secrets.X }}), and logs are masked automatically.
  • Output: outputs.<id>.value: ${{ steps.S.outputs.K }}.
  • Referencing an action in the same repository: use the 2026 self-reference syntax (it resolves to the commit currently running, needs no prior checkout, and is not supported on GHES); the traditional $/path/to/action approach ./path relies on content checked out into the workspace, which in cross-repository calls points to the caller's workspace.

When: how to choose

DimensionReusable workflowComposite action
Reuse granularityone or more jobs (can include matrix, needs dependencies, environment approvals)a sequence of steps
Where it is calledjobs.<id>.usessteps[*].uses
runnerdeclared by the called job itself runs-onshares the caller job's runner and filesystem
secretsa dedicated secrets channel, with support for inheritcan only be passed via inputs
Logseach job and each step is visible separatelycollapsed into a single step of the caller (expandable)
Best for“standard pipelines”: build, test, release, deploy; trusted builds (SLSA L3); mandatory approvals“building blocks”: installing toolchains, logging in, caching, common checks
Nesting limit10 levels / 50 distinctper the docs (composite actions can also nest within each other)
Common misconceptions① “secrets: inherit “Secrets propagate all the way down” is wrong: they only go to the direct callee. ② “The caller writes env:, and the called workflow can read it” is wrong: it cannot. ③ “The called workflow can grant itself packages: write” is wrong: it can only lower permissions, not raise them, and exceeding the scope granted by the caller fails at startup. ④ “A reusable workflow can be placed in .github/workflows/shared/ subdirectories” is wrong: subdirectories are not supported. ⑤ “A run step in a composite action works without a shell” is wrong: composite run steps must specify a shell.

Architecture diagram: data and permissions in one call

Caller myorg-lab/myapp .github/workflows/ci.yml (on: push) job: build (calling job) uses: …/build-test.yml@v1 with: python-version: "3.12" secrets: inherit permissions: contents read, packages write, id-token write (cannot write runs-on / steps / env) job: deploy needs: build ${{ needs.build.outputs.image-digest }} Called myorg-lab/platform-workflows .github/workflows/build-test.yml (on: workflow_call) inputs: python-version (string)secrets: REGISTRY_TOKEN (optional)outputs: image-digest ← jobs.build.outputs.digest job: testruns-on: ubuntu-24.04permissions:contents: read job: buildneeds: testpackages: writesteps.push.outputs github context = caller (push event)env does not propagate · billing and hosted runners belong to the caller inputs + secrets outputs Permission check Called job requests⊆ granted by the calling job? Yes → issue as requestedGITHUB_TOKEN No → startup fails:“is requesting … butis only allowed …”
Figure 1-1: inputs/secrets flow top-down, outputs flow bottom-up; permissions can only be narrowed; context, billing, and hosted runners all belong to the caller

Comparison diagram: how secrets pass through three nested levels

A (myapp/ci.yml)secrets: DB_PASS, NPM_TOKEN,SLACK_WEBHOOK B (deploy.yml)inherits all 3 via inheritthen explicitly passes only SLACK_WEBHOOK C (notify.yml)only SLACK_WEBHOOKDB_PASS → empty string secrets: inherit SLACK_WEBHOOK: … A secret that is not passed resolves to an empty string in the called workflow without an error. Add required: true to critical secrets so that errors surface early
Figure 1-2: secrets are passed only to direct callees

Core animation: reusable workflow call chain (inputs / secrets / outputs and permission intersection)

First choose the permissions granted by the calling job and how secrets are passed, then click “Start call” to step through how GitHub resolves uses, checks access and permissions, and issues GITHUB_TOKEN, and returns outputs to the caller. The called workflow's build job always requests contents: read,packages: write,id-token: write,attestations: write, and declares REGISTRY_TOKEN as required: true.

calling job's permissions
secrets passing method
push eventmyapp ci.yml Resolve uses@v1 → commit SHA Validateaccess · inputs · secrets · permissions Called jobstest → build Return outputsneeds.build.outputs
Choose the permissions and secrets method, then click “Start call”. The default configuration is missing attestations: write, to see what happens.
$ git push org main

Core syntax and commands

Syntax / commandPurposeNotes
on: workflow_call:Declare callablecan be kept alongside workflow_dispatch for easier standalone debugging
jobs.X.uses: org/repo/.github/workflows/f.yml@refCross-repository callref can be a SHA, tag, or branch; within the same repository it can be written ./.github/workflows/f.yml (no @ref; uses the same commit)
secrets: inheritPass all secrets visible to the callersame organization/enterprise only
gh workflow run f.yml -f k=vManual trigger (requires workflow_dispatch)Debug the reusable workflow itself
gh run view RUN --json jobsView the job names produced by the callCalled job names look like build / test
gh api repos/O/R/actions/runs/ID --jq .referenced_workflowsAudit which reusable workflows and SHAs this run usedPlatform team inventories usage

Called side: platform-workflows/.github/workflows/python-build.yml

name: python-build
on:
  workflow_call:
    inputs:
      python-version:
        type: string
        default: "3.12"
      image-name:
        type: string
        required: true
      push:
        type: boolean
        default: false
    secrets:
      REGISTRY_TOKEN:
        required: false
    outputs:
      image-digest:
        description: "Digest of the pushed image"
        value: ${{ jobs.build.outputs.digest }}

permissions: {}            # clear at file level first; each job declares its own

jobs:
  test:
    runs-on: ubuntu-24.04
    permissions:
      contents: read
    steps:
      - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
        with:
          persist-credentials: false
      - uses: actions/setup-python@v7   # example; in production, pin the SHA as well
        with:
          python-version: ${{ inputs.python-version }}
          cache: pip
      - run: pip install -r requirements.txt -r requirements-dev.txt
      - run: pytest -q

  build:
    needs: test
    runs-on: ubuntu-24.04
    permissions:
      contents: read
      packages: write
    outputs:
      digest: ${{ steps.push.outputs.digest }}
    steps:
      - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
        with:
          persist-credentials: false
      - uses: docker/login-action@8aa5831fb8d48d8f76594c7ddde61ae58019f550 # v4.8.0
        with:
          registry: ghcr.io
          username: ${{ github.actor }}
          password: ${{ secrets.REGISTRY_TOKEN || secrets.GITHUB_TOKEN }}
      - id: push
        uses: docker/build-push-action@c3c9e263c25d99ce0380d002d59b67737d91b0dc # v7.4.0
        with:
          push: ${{ inputs.push }}
          tags: ghcr.io/${{ inputs.image-name }}:${{ github.sha }}

Caller: myapp/.github/workflows/ci.yml

name: ci
on:
  push:
    branches: [main]
  pull_request:

permissions: {}

jobs:
  build:
    uses: myorg-lab/platform-workflows/.github/workflows/python-build.yml@v1
    with:
      image-name: ${{ github.repository }}
      push: ${{ github.event_name == 'push' }}
    secrets: inherit
    permissions:
      contents: read
      packages: write

  report:
    needs: build
    runs-on: ubuntu-24.04
    permissions: {}
    steps:
      - env:
          DIGEST: ${{ needs.build.outputs.image-digest }}
        run: echo "image digest = $DIGEST" >> "$GITHUB_STEP_SUMMARY"

How to verify: The run graph shows build / test,build / build two jobs,report and the summary of Common errors: Caller written as uses: myorg-lab/platform-workflows/python-build.yml@v1 (missing .github/workflows/); or adding runs-on to the calling job. Production use: The platform team tags platform-workflows with v1/v1.2.0 tags, and application repositories track them with Dependabot (module 6).

Composite action: platform-workflows/actions/setup-myapp/action.yml

name: setup-myapp
description: Install Python and myapp dependencies with pip cache
inputs:
  python-version:
    description: Python version
    default: "3.12"
outputs:
  python-path:
    description: Path of the python interpreter
    value: ${{ steps.py.outputs.python-path }}
runs:
  using: composite
  steps:
    - id: py
      uses: actions/setup-python@v7
      with:
        python-version: ${{ inputs.python-version }}
        cache: pip
    - name: Install dependencies
      shell: bash                      # composite run steps must specify a shell
      run: |
        python -m pip install --upgrade pip
        pip install -r requirements.txt -r requirements-dev.txt
    steps:
      - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
      - uses: myorg-lab/platform-workflows/actions/setup-myapp@v1
        with:
          python-version: "3.12"
      - run: pytest -q

Lab 1: extract an organization-shared build-test workflow (about 8 min)

Write a reusable workflow and a composite action in platform-workflows: save the “Commands” page's python-build.yml as .github/workflows/python-build.yml,action.yml as actions/setup-myapp/action.yml, then replace the setup-python + pip steps in python-build's test job with uses: $/actions/setup-myapp (same-repository self-reference, which follows the called workflow's commit).
cd ~/src/platform-workflows
mkdir -p .github/workflows actions/setup-myapp
# …write both files…
git add . && git commit -m "feat: python-build reusable workflow and setup-myapp action"
git push origin main
git tag -a v1.0.0 -m "v1.0.0" && git tag -f v1 && git push origin v1.0.0 v1

First use the traditional approach of a “movable v1 tag + immutable v1.0.0” tag; module 2 covers how to adjust after enabling immutable releases.

In myapp, change it to call: use the “Commands” page's ci.yml to replace the original CI.
cd ~/src/myapp
git switch -c reuse-ci
# …write .github/workflows/ci.yml…
git commit -am "ci: call shared python-build workflow" && git push -u org reuse-ci
gh pr create -R $ORG/myapp --fill
gh run watch -R $ORG/myapp
✓ reuse-ci ci · 1234567890
Triggered via pull_request less than a minute ago

JOBS
✓ build / test in 41s (ID 3141592653)
✓ build / build in 58s (ID 3141592654)
✓ report in 3s (ID 3141592655)
Audit which reusable workflows this run referenced:
RUN=$(gh run list -R $ORG/myapp -L1 --json databaseId --jq '.[0].databaseId')
gh api repos/$ORG/myapp/actions/runs/$RUN --jq '.referenced_workflows'
[{"path":"myorg-lab/platform-workflows/.github/workflows/python-build.yml@v1","ref":"refs/tags/v1","sha":"9f2c1e0…"}]
Deliberately trigger a permissions error: change the calling job's packages: write to packages: read then push; the run fails at startup (no job runs), with an error like The nested job 'build' is requesting 'packages: write', but is only allowed 'packages: read'. Change it back and push again.
Verify env does not propagate: add env: FOO: bar at the top level of ci.yml, and in a step of python-build.yml run: echo "FOO=$FOO", after running the logs show FOO=. Conclusion: share config using vars or inputs. Delete these two changes after the lab.

Case 1: unified CI template for 200 microservices

Problem: Each repository maintained its own CI; upgrading the Node runtime took a whole quarter. Approach: The platform team turned “lint → test → build → scan → push” into 4 reusable workflows, placed in a platform-workflows repository protected by rulesets; application repositories only write 15 lines of calling YAML. Configuration: Entry workflows are split by language (python-build, node-build, go-build); the shared scan and push steps are called through nesting (3 levels, far below the 10-level limit). Limitations: A calling job cannot write environment; production approval must sit in the called side's deploy job. As teams need more and more parameters, control the number of inputs so the template does not turn into a “configuration language”.

Case 2: secrets: inherit leads to over-authorization

Problem: A security audit found that a public reusable workflow maintained by a third party was used with secrets: inherit a call, meaning all organization secrets (including the production database password) were exposed to it. Approach: Stipulate that inherit is only used for the organization's own platform-workflows; external workflows must always receive explicitly passed minimal secrets and be pinned by SHA. Note: In fact, inherit cross-organization calls never pass secrets anyway, but “shadow template repositories” inside the same organization are just as dangerous. Use zizmor (module 6) to check for secrets-inherit this class of problem.

Case 3: a concurrency group name collision cancels the caller

Problem: The caller and the called workflow both wrote concurrency: group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true, so the called workflow cancelled the caller itself as soon as it started. Cause: The called side's github.workflow is the caller's name. Fix: Add a fixed prefix to the called side's concurrency group (for example python-build-${{ github.ref }}), or set concurrency only in the caller.

Common errors and fixes

error parsing called workflow ".github/workflows/ci.yml" -> "myorg-lab/platform-workflows/.github/workflows/python-build.yml@v1" : workflow was not found.

Cause: Wrong path or tag; or the called repository is private and not authorized in Settings → Actions → General → Access; or the caller is a public repository while the called one is private (public callers can only call public workflows); or the repository was renamed (redirects are not supported).

gh api repos/myorg-lab/platform-workflows/contents/.github/workflows/python-build.yml?ref=v1 --jq .path
gh api repos/myorg-lab/platform-workflows/actions/permissions/access

Fix: Confirm the file is in .github/workflows/ the root directory and the tag exists; for private repositories, enable access from within the organization.

The nested job 'build' is requesting 'packages: write', but is only allowed 'packages: read'.

Cause: The called job requests permissions beyond the scope granted by the calling job (permissions can only be lowered, not raised).

Fix: Add it to the calling job's permissions block; or confirm the called side really needs it (least privilege). Note that once the calling job writes permissions, every unlisted item becomes none.

Invalid input, python_version is not defined in the referenced workflow.

Cause:with The keys in inputs do not match those of the called side (case, underscores, and hyphens). When a required input is not passed, the error is Input required and not supplied.

Fix: Check against the called side's on.workflow_call.inputs; types must match too (do not write boolean as the string "true").

The secret is empty in the called side, and the login step reports Error: Username and password required

Cause: The caller did not pass the secret (neither inherit nor explicit mapping); a middle layer of the A→B→C chain did not keep passing it; or a cross-organization call used inherit. An unpassed secret resolves to an empty string,and does not error.

Fix: Add required: true to the critical secret on the called side so that a missing value fails at startup; pass it explicitly at every level when nesting.

Unexpected value 'runs-on' / 'steps' / 'environment' (job that calls a reusable workflow)

Cause: A calling job can only use name, uses, with, secrets, strategy, needs, if, concurrency, permissions, and cache-mode.

Fix: Move runs-on, environment, timeout, etc. into the called side's job, and turn them into inputs if necessary.

Command-line questions
1. Use one command to list the reusable workflows referenced by myapp's most recent run, along with their resolved SHAs.
gh api repos/$ORG/myapp/actions/runs/$(gh run list -R $ORG/myapp -L1 --json databaseId --jq '.[0].databaseId') --jq '.referenced_workflows[] | "\(.path) \(.sha)"'
2. Write a job that calls a reusable workflow in the same repository (file .github/workflows/lint.yml) and grants only contents: read.
jobs:
  lint:
    uses: ./.github/workflows/lint.yml
    permissions:
      contents: read
Scenario analysis
The team wants “every repository must pass the same security scan before deploying to production, and production deployment requires SRE approval.” Should this use a reusable workflow or a composite action? Where does the approval go?

Use a reusable workflow: it can contain multiple jobs (scan, build, deploy) and needs dependencies; write environment: production in the called side's deploy job and configure required reviewers in the repository environment (a calling job cannot write environment). A composite action is just a sequence of steps; it can neither span jobs nor attach an environment. Combine it with the module 7 ruleset “require workflow to pass” or an Actions policy to make sure repositories cannot bypass it.

Verified instructional videos

▶
GitHub Actions Reusable Workflows FULL TUTORIAL with Examples: Templates on Steroids — CoderDave
English · full walkthrough of reusable workflow inputs/secrets/outputs (recorded earlier; for nesting limits and other figures, this lesson governs: 10 levels / 50 workflows)
▶
Composite Actions VS Reusable Workflows in GitHub Actions [2023 Update] — CoderDave
English · comparison and selection between the two reuse methods
▶
Create Your First Reusable Workflow — Mickey Gousset
English · short demo: create and call from scratch

Official documentation

Video storyboard (about 90 seconds)

This courseware cannot generate video/MP3 directly; the storyboard below can be handed to a video tool.

Shot 1 · 0–20s
Visual: 100 repository icons, each with a nearly identical ci.yml; several are marked in red as “outdated action”.
Narration: copy-pasted pipelines drift. Reusable workflows let the platform team maintain just one.
Shot 2 · 20–45s
Visual: the calling job emits three colored lines—inputs, secrets, and permissions—entering the two jobs of the called workflow.
Narration: inputs and secrets flow in from the caller, and permissions can only be narrowed. If the called side asks for one extra permission, the run fails at startup.
Shot 3 · 45–70s
Visual: three boxes A, B, C; secrets are fully inherited from A to B, and only one key is left from B to C.
Narration: secrets are passed only to direct callees. An unpassed secret is an empty string, so mark critical secrets as required.
Shot 4 · 70–90s
Visual: on the left, a reusable workflow for a “whole set of jobs”; on the right, a composite action for a “sequence of steps”.
Narration: for cross-job flows, approvals, or trusted builds, use a reusable workflow; for a building block, use a composite action.
or score 70% or more on the quiz

Module 2 · Writing custom actions (JavaScript / Docker / composite)

08:00 – 15:00 · An action is a repository directory with an action.yml; the runner reads runs.using to decide whether to run it with Node, in a container, or expand it into steps
7 minruns.using: node24immutable releases 2025-10 GA★★★★
Learning goals
  • Read action metadata action.yml: name / description / inputs / outputs / runs / branding.
  • Write a node24 JavaScript action: @actions/core read inputs, write outputs, and mark failures; use @vercel/ncc (or rollup) to bundle dependencies into a single dist/index.js.
  • Know when Docker actions and composite actions apply, and their limitations (Docker actions only run on Linux runners).
  • Be able to publish to Marketplace and understand v1 the trade-off between major-version tag conventions and immutable releases.
Prerequisites: Module 1; Node.js basics. Importance:★★★★

What: three types of actions

TyperunsExecution methodAdvantagesLimitations
JavaScriptusing: node24 (or node20)
main, optionally pre / post and pre-if / post-if
run directly with the Node runtime built into the runner main pointing to a JS fileFastest startup; runs on Linux / Windows / macOS; post can be used for cleanupDependencies must be bundled into the repository (the runner will not npm install)
Docker containerusing: docker
image: Dockerfile or docker:// image,args,entrypoint,env
the runner builds the Dockerfile (or pulls the image) on each run and mounts the workspace into the container to executecan use any language and lock down the whole toolchainLinux runners only; using a Dockerfile means building every time, which is slower
Compositeusing: composite
steps (run needs a shell / uses other actions)
expands steps into the caller's job to executeno code required; can compose existing actionsno pre/post; YAML is hard to maintain when logic gets complex

Why: when it is worth writing your own

The Marketplace already has tens of thousands of actions, but organizations often have specific needs: calling internal APIs, checking internal standards, combining several public actions with default values. Another reason to write your own is security: rather than referencing a third-party action of a few dozen lines maintained by strangers, implement it in a few lines of composite or JS within the organization to reduce supply-chain exposure (the tj-actions incident in module 6 is an example).

How: how the runner passes inputs / outputs to the action

  • Inputs: the runner turns each with key into an environment variable INPUT_<NAME> (uppercase, spaces replaced with underscores), and the action core.getInput('name') reads it; Docker actions can also pass arguments via args .
  • Outputs: the action appends to the $GITHUB_OUTPUT file key=value (core.setOutput helps with this); the old ::set-output workflow commands are deprecated.
  • Failures: a non-zero process exit code fails the step; core.setFailed(msg) outputs error annotations and sets exit code 1.
  • Logs and masking: core.info/warning/error,core.startGroup; core.setSecret(v) lets the runner mask a runtime value in the logs.

Bundling JavaScript actions

The runner only downloads the action repository's content at the specified ref,does not run npm install. So you either node_modules commit it (not recommended) or use a bundler to combine source and dependencies into one file. The classic approach is @vercel/ncc (0.45.0, 2026-08): its input is "type": "module" the entry file inside the package .js — when it is ESM it outputs an ES module automatically; GitHub's official template actions/javascript-action has switched to rollup. @actions/core Currently 3.0.1 (ESM); the official template's engines.node is >=24.

Version and release conventions

  • convention: publish v1.2.3 semantic version tags like this, while maintaining a movable major-version tag v1 (and an optional v1.2) that points to the latest compatible commit, so users who write @v1 get fixes automatically.
  • immutable releases (2025-08 public preview,2025-10-28 GA): once enabled at the repository or organization level,tags of published Releases cannot be moved or deleted, and assets cannot be modified or deleted. After a Release is deleted its tag can be removed, but the same tag name can never be reused (even deleting and recreating the repository is not allowed, which prevents “repository resurrection” attacks); it also automatically generates release attestations, which can be verified with gh release verify to verify. Titles and notes remain editable.
  • How the two coexist (official doc “Using immutable releases and tags to manage your action's releases”): create a GitHub Release for each fixed version (for example v1.0.0, immutable); for major and minor tags v1,v1.1 create only Git tags, not Releases, so that they can still be git tag -f + git push -f moved. Users who want determinism should reference a SHA or an immutable version tag.
  • Marketplace: public repository, root directory with only one action.yml (subdirectory ones are not listed automatically),name a globally unique name, acceptance of the Marketplace developer agreement, and checking “Publish this Action to the GitHub Marketplace” when publishing a Release; publishing requires 2FA; GitHub does no manual review.
Runtimenode12,node16 has been removed; node20 is still an optional value listed in the metadata docs, but it has entered the deprecation process, so new actions should use node24 (actions/checkout has been node24 since v5). For the exact node20 retirement date, follow the GitHub Changelog.
Common misconceptions① “Once you list package.json dependencies, the runner will install them for me”—no, they must be bundled. ② “Docker actions also run on Windows/macOS runners”—only on Linux. ③ “After enabling immutable releases you can't use the v1 tag”—you can, as long as v1 is not attached to a Release. ④ “Using @v1 is secure”—tags can be moved by maintainers (or attackers); the strongest pinning is a SHA or lock file (module 6).

Structure diagram: a JavaScript action repository

myorg-lab/check-healthz-action action.ymlruns.using: node24 src/index.jsSource (ESM) package.json"type":"module" dist/index.jsncc bundle output (committed) dist/licenses.txt .github/workflows/test.yml, check-dist.yml README.mdUsage and inputs/outputs Release Tags and Releases v1.0.0 ← Release (immutable) v1.1.0 ← Release (immutable) v1.1 ← Git tag only (movable) v1 ← Git tag only (movable) Releases automatically carry a release attestation Marketplace: a single action.yml at the root Users uses: org/action@v1convenient, but tags can move uses: org/action@v1.1.0immutable release guarantees it does not change uses: org/action@<40-character SHA> # v1.1.0most certain + Dependabot updates
Figure 2-1: source + bundled output + metadata; immutable versioned Releases and movable major-version tags coexist

Flowchart: how the runner executes a step's uses

“Set up job”Download all actions Read action.ymlruns.using node24 → node dist/index.js docker → build/pull → docker run composite → expand steps INPUT_* environment variables in · GITHUB_OUTPUT outExit code determines step success or failure
Figure 2-2: the dispatch point for the three action types is runs.using

Interactive comparison: execution paths of the three action types on the runner

Choose an action type, then step through it. The log panel simulates the runner's real log lines (times are illustrative) and shows what the runner actually does at each step.

Choose an action type to start.

Core commands and files

CommandPurposeNotes
npm i @actions/coreOfficial toolkitgetInput / setOutput / setFailed / summary
npx @vercel/ncc build src/index.js -o dist --license licenses.txtBundle into a single fileESM package automatically outputs an ES module
npx @github/local-action . src/main.js .envRun a JS action locally for testingDebugging tool included in the official template
gh release create v1.0.0 --generate-notesCreate an immutable versioned ReleaseMarketplace publishing must be checked on the web
git tag -f v1 v1.0.0^{} && git push -f origin v1Move a major-version tagDo not attach a Release to v1
gh release verify v1.0.0Verify a release attestationOnly immutable releases have attestations

JavaScript action: action.yml

name: check-healthz
description: Poll an HTTP health endpoint until it returns 200
author: myorg-lab
branding:
  icon: activity
  color: green
inputs:
  url:
    description: Health endpoint URL
    required: true
  timeout-seconds:
    description: Give up after N seconds
    default: "60"
outputs:
  elapsed:
    description: Seconds until healthy
runs:
  using: node24
  main: dist/index.js

src/index.js (ESM, @actions/core 3.x)

import * as core from '@actions/core'

async function run() {
  const url = core.getInput('url', { required: true })
  const timeout = Number(core.getInput('timeout-seconds') || '60')
  const start = Date.now()
  core.startGroup(`Polling ${url}`)
  while ((Date.now() - start) / 1000 < timeout) {
    try {
      const res = await fetch(url)             // Node 24 has fetch built in
      core.info(`HTTP ${res.status}`)
      if (res.status === 200) {
        const elapsed = Math.round((Date.now() - start) / 1000)
        core.endGroup()
        core.setOutput('elapsed', String(elapsed))
        await core.summary.addRaw(`✅ ${url} healthy after ${elapsed}s`).write()
        return
      }
    } catch (e) {
      core.info(`not ready: ${e.message}`)
    }
    await new Promise(r => setTimeout(r, 3000))
  }
  core.endGroup()
  core.setFailed(`${url} not healthy within ${timeout}s`)
}

run()
npm init -y && npm pkg set type=module engines.node=">=24"
npm i @actions/core@3
npm i -D @vercel/ncc@0.45.0
npx ncc build src/index.js -o dist --license licenses.txt
ls dist/
ncc: Version 0.45.0
ncc: Compiling file index.js into ESM
  46kB  dist/licenses.txt
 210kB  dist/index.js
 256kB  [1203ms] - ncc 0.45.0
index.js  licenses.txt

Docker action (Linux runners only)

name: hadolint-lite
description: Lint a Dockerfile
inputs:
  dockerfile:
    default: Dockerfile
runs:
  using: docker
  image: docker://hadolint/hadolint:v2.12.0-debian   # prebuilt image, avoids rebuilding each time; in production, use a @sha256 digest
  entrypoint: hadolint
  args:
    - ${{ inputs.dockerfile }}

The image tag is an example; verify it on Docker Hub before use. Using image: Dockerfile makes the runner rebuild every time it runs docker build; pushing the image to GHCR in advance and referencing it with docker://ghcr.io/…@sha256:… speeds things up significantly and pins the content.

Lab 2: write a JS action and use it in myapp (about 7 min)

Create the action repository and bundle it:
gh repo create $ORG/check-healthz-action --public --clone && cd check-healthz-action
# write the action.yml and src/index.js from the “Commands” page
npm init -y && npm pkg set type=module engines.node=">=24"
npm i @actions/core@3 && npm i -D @vercel/ncc@0.45.0
npx ncc build src/index.js -o dist --license licenses.txt
printf 'node_modules/\n' > .gitignore
git add . && git commit -m "feat: check-healthz action" && git push origin main
Add a check that “dist is up to date” (to prevent someone from changing src and forgetting to rebundle):
name: check-dist
on: [push, pull_request]
permissions:
  contents: read
jobs:
  check:
    runs-on: ubuntu-24.04
    steps:
      - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
        with:
          persist-credentials: false
      - uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0
        with:
          node-version: 24
      - run: npm ci
      - run: npx ncc build src/index.js -o dist --license licenses.txt
      - run: git diff --exit-code dist/ || (echo "::error::dist/ is stale, run ncc build" && exit 1)
Publish an immutable version + a movable major-version tag (first, in the repository Settings → General → Releases, check Enable release immutability; the UI location follows the docs):
gh release create v1.0.0 --title "v1.0.0" --generate-notes
git fetch --tags
git tag -f v1 v1.0.0^{} && git push -f origin v1     # v1 is only a Git tag, no Release
gh release verify v1.0.0
Resolved tag v1.0.0 to sha1:5b0e…
Loaded attestation from GitHub API
✓ Release v1.0.0 verified!

Try git tag -f v1.0.0 HEAD && git push -f origin v1.0.0; the push will be rejected—this is the protection that immutable releases provide.

Use in myapp: in one job, start compose and then call:
      - run: docker compose up -d --build
      - id: hc
        uses: myorg-lab/check-healthz-action@v1
        with:
          url: http://localhost:8000/healthz
          timeout-seconds: "90"
      - run: echo "healthy after ${{ steps.hc.outputs.elapsed }}s"
(optional) publish to Marketplace: in the action repository, open action.yml, click the banner Draft a release, and check “Publish this Action to the GitHub Marketplace”. name: check-healthz The name may already be taken, so you need a unique name. Do not actually publish lab actions; to unlist one, edit each Release and uncheck the box.

Case 1: an internal deployment action replaces 3 third-party actions

Problem: The deployment process depended on 3 niche third-party actions (downloading kubectl, rendering templates, calling an internal API); their maintainers were inactive and the security team could not assess them. Approach: Use one composite action that combines GitHub's official action with 30 lines of shell, keep it in a private repository inside the organization, and share it through “Accessible from repositories in the organization”. Limitation: Once a private action repository is opened to the organization, external collaborators in other repositories can indirectly see its output through run logs.

Case 2: a Docker action slows the pipeline

Problem: A Docker action written in Python (image: Dockerfile) took 2 minutes to build on every run. Approach: In the action repository's release workflow, push the image to GHCR,action.yml and change it to image: docker://ghcr.io/org/tool@sha256:…; or rewrite it as a JS action. Result: This step dropped from 2 min 10 s to 15 s.

Case 3: the release process fails after enabling immutable releases

Problem: Following JasonEtco/build-and-tag-action the practice of “force-pushing the major-version tag to the Release commit” fails once immutable releases are enabled. Approach: Following the official advice: the versioned Release (v1.4.2) is immutable,v1 and the movable tag is moved only as a Git tag; first create a draft Release, upload all assets, then publish. Limitation: If a wrong version is published by mistake, you can only publish a new version (the same tag name cannot be reused).

Common errors and fixes

Error: Cannot find module '@actions/core' / ERR_MODULE_NOT_FOUND

Cause: the bundled dist/ was not committed, or main points to the source src/index.js.

Fix: run ncc/rollup to bundle, then commit dist/; add the check-dist workflow.

Container action is only supported on Linux

Cause: a runs.using: docker action was used on windows-latest / macos-latest.

Fix: run the job on a Linux runner instead, or rewrite it as a JS / composite action.

Required property is missing: shell

Cause: a run step in the composite action has no shell.

Fix: add shell: bash to each run step (or pwsh, etc.).

The `set-output` command is deprecated and will be disabled soon.

Cause: the old action still prints ::set-output to stdout.

Fix: upgrade @actions/core, or change it to echo "k=v" >> "$GITHUB_OUTPUT" in the shell.

! [remote rejected] v1.0.0 -> v1.0.0 (… cannot update a tag that belongs to an immutable release)

Cause: after enabling immutable releases, the tags of published Releases cannot be moved or deleted (follow the actual error text).

Fix: publish a new patch version; do not attach a Release to the major-version tag.

Command-line questions
1. Use ncc to bundle src/index.js into dist, and include the third-party license file.
npx @vercel/ncc build src/index.js -o dist --license licenses.txt
2. Point the movable major-version tag v2 at the commit of v2.3.1 and push it.
git tag -f v2 v2.3.1^{}
git push -f origin v2
Scenario analysis
You need to write an action that uploads diagnostic logs at the end of a job, whether it succeeds or fails, and it must run on a Windows runner. Which type should you choose, and why?

JavaScript action: only JS actions support post (used with post-if: always(), which defaults to always) for cleanup work, and it runs on Windows/macOS/Linux. Docker actions only run on Linux; composite actions have no pre/post.

Verified instructional videos

▶
Create Your First Custom GitHub Action — Mickey Gousset
English · creating a custom action from scratch
▶
Custom GitHub Actions in Node.js - GitHub Actions JavaScript Tutorial — Colby Fayock
English · JS action and ncc bundling (recorded earlier; use node24 for the runtime)
▶
Ultimate Guide to GitHub Composite Actions (Complete Walkthrough!) — Yankee Maharjan
English · full demo of a composite action

Official documentation

Video storyboard (about 80 seconds)

Shot 1 · 0–20s
Visual: the runs.using line in action.yml is highlighted, splitting into three paths: Node, container, and expanded steps.
Narration: the runner looks at runs.using to decide how to run the action.
Shot 2 · 20–45s
Visual: src and node_modules are compressed into a single dist/index.js file.
Narration: the runner does not install dependencies for you, so a JavaScript action must be bundled.
Shot 3 · 45–80s
Visual: v1.0.0 is locked, and the v1 tag is moved to a new commit like a sticky note.
Narration: a versioned Release is immutable, and the major-version tag is only a Git tag, so it can keep moving.
or score 70% or more on the quiz

Module 3 · Release automation: releases, tags, and changelogs

15:00 – 22:00 · Tags belong to Git, and Releases belong to GitHub: a Release = tag + notes + assets (+ attestations when immutable)
7 mingh release create --generate-notesDraft first, publish later★★★★
Learning goals
  • Distinguish Git tags (lightweight / annotated) from GitHub Releases, and know the three Release states: draft, pre-release, and latest.
  • Use .github/release.yml to classify automatically generated release notes by PR label, and use gh release create --generate-notes to publish in a workflow.
  • Upload release assets and checksums, and follow the order “draft → upload all assets → publish” (required with immutable releases).
  • Know where release-please / semantic-release fit in this chain, and connect them to GitHub Releases on top of the configuration already set up in the Git course.
Prerequisites:Git Hour 5Module 4 (signed tags) and module 6 (conventional commits, semantic versioning, release-please / semantic-release). Importance:★★★★

What: tags, Releases, and assets

  • Git tag: a reference pointing to a commit; an annotated tag (git tag -a) carries an author, date, and message, and can be signed. Tags alone do not create a page on GitHub.
  • GitHub Release: a GitHub object built on top of a tag, containing a title, notes (Markdown),assets and automatically attached source zip/tar.gz archives. Status: Draft (visible only to people with write access; the tag may not exist yet),Pre-release,Latest (determined automatically by semantic version when not specified manually).
  • Automatically generated release notes: GitHub builds notes from the PRs, contributors, and new contributors merged between the previous Release tag and this tag, along with a “Full Changelog” comparison link. You can configure them in .github/release.yml to group by PR label, and exclude labels or authors (such as dependabot).

Why: why automate releases

The most common problems with manual releases: forgetting to upload a binary for one platform, missing notes, tagging the wrong commit, and quietly replacing assets after release (users then get files whose checksums don't match). Putting the release into a workflow, combined with immutable releases and build attestations (module 5), guarantees that “every file in this Release came from this CI build, and it will not be replaced after release.”

How: two mainstream ways to decide versions

Manual tagging + workflow publishingrelease-pleasesemantic-release
Who decides the version numbera person (pushes v1.4.0 the tag)computed from conventional commits; opens a “Release PR”, and after merging it tags and creates the Releasecomputed from conventional commits; tags and creates the Release directly in CI
ChangelogGitHub generates the notes automaticallyMaintained CHANGELOG.md + Release notesplugin generates notes; a CHANGELOG can be written
Review pointTag push permission (tag ruleset)Review of the Release PRNo manual review point; suits highly automated flows
seethis moduleGit Hour 5 · module 6(googleapis/release-please-action v5.0.0, semantic-release)

Key facts about publishing from a workflow

  • Creating a Release requires GITHUB_TOKEN of the contents: write.
  • Use GITHUB_TOKEN a Release created or a tag pushed with does not trigger a new workflow run workflow_dispatch ( repository_dispatch and on: release are excepted). So the chain “release-please creates a Release → another release_created workflow builds the assets” will not trigger with the default token; the common fix is to continue building and uploading in the same workflow using release-please's output (
  • immutable releases), or use a GitHub App token. gh release create --draft : after release, assets cannot be added, removed, or modified. The correct order: gh release edit --draft=false→ upload all assets → release attestation. Once enabled, GitHub also generates gh release verify TAG for the Release (tag, commit SHA, asset digests), which users verify with and gh release verify-asset TAG FILE
  • Tag protection: use a tag ruleset to restrict who can create, update, or delete v* tags (the Git course's third lesson covered rulesets), so that arbitrary contributors cannot trigger a release by pushing a tag.
  • Signing: tags created on the GitHub web or via API are signed by GitHub and show as Verified; for signing tags locally, see module 4 of Git Hour 5.
Common misconceptions① “Deleting a Release deletes the tag”—no, the tag remains (after an immutable Release is deleted its tag can be removed, but the name cannot be reused). ② “A draft Release is visible to everyone”—only people with write access can see it. ③ “Release notes are generated from commit messages”—GitHub's automatic notes are based on the merged PRs; generating a CHANGELOG from conventional commits is the job of release-please / semantic-release. ④ “If a workflow creates a Release, the on: release workflow runs automatically”—not when using GITHUB_TOKEN.

Flowchart: from tag to immutable Release

git pushtag v1.4.0 Tag rulesetwho can create v* tags release.ymlon: push tags v* Build + attestationwheel, SHA256SUMS DraftUpload all assets Publish🔒 Immutable After publishing (immutable releases enabled) Tag locked to the commit · assets cannot be added, removed, or modified · release attestation generated automatically Editable: title, notes, pre-release / latest flags · after the Release is deleted, the same tag name cannot be reused
Figure 3-1: the draft stage is the only window in which assets can be adjusted

Diagram: how automatically generated release notes are categorized

PRs merged between v1.3.0 and v1.4.0 #41 feat: add /metrics [enhancement] #42 fix: redis timeout [bug] #43 bump gunicorn [dependencies] #44 docs: README [docs] #45 chore: lint [ignore-for-release] .github/release.ymlexclude: ignore-for-releasecategories matched by label"*" catch-all ## What's Changed 🎉 Features: #41🐛 Fixes: #42📦 Dependencies: #43Other: #44New Contributors · Full Changelog link
Figure 3-2: #45 is excluded; PRs that match no category fall into the “*” category

Interactive timeline: publishing order and immutable releases

Switch between “whether immutable releases are enabled” and “publishing order”, click play, and watch which step fails and what end users finally see.

Choose a combination, then click play.

Core commands

CommandPurposeKey parameters
gh release create TAG [files…]Create a Release (when the tag does not exist, it is created as specified by --target )--draft,--prerelease,--generate-notes,--notes-start-tag,--verify-tag,--latest,--title,file#display name
gh release upload TAG files…Upload assets--clobber overwrite same name (not valid for immutable Releases)
gh release edit TAG --draft=falsePublish a draftcan also change the title, notes, and latest flag
gh release view / list / downloadView and downloaddownload -p '*.whl'
gh release verify TAG / verify-asset TAG FILEVerify release attestations and assetsrequires an immutable Release
gh api repos/O/R/releases/generate-notes -f tag_name=v1.4.0Generate notes only, without publishingPreview notes

.github/release.yml

changelog:
  exclude:
    labels: [ignore-for-release]
    authors: [dependabot]
  categories:
    - title: 💥 Breaking Changes
      labels: [breaking-change]
    - title: 🎉 Features
      labels: [enhancement]
    - title: 🐛 Fixes
      labels: [bug]
    - title: Other Changes
      labels: ["*"]

.github/workflows/release.yml (myapp)

name: release
on:
  push:
    tags: ["v*.*.*"]
permissions: {}
jobs:
  build:
    runs-on: ubuntu-24.04
    permissions:
      contents: read
    steps:
      - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
        with:
          persist-credentials: false
      - uses: actions/setup-python@v7
        with:
          python-version: "3.12"
      - run: |
          pip install build
          python -m build                    # build dist/*.whl and dist/*.tar.gz
          cd dist && sha256sum * > SHA256SUMS
      - uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
        with:
          name: dist
          path: dist/

  publish:
    needs: build
    runs-on: ubuntu-24.04
    permissions:
      contents: write                         # create the Release
    steps:
      - uses: actions/download-artifact@v8
        with:
          name: dist
          path: dist
      - env:
          GH_TOKEN: ${{ github.token }}
          TAG: ${{ github.ref_name }}
        run: |
          gh release create "$TAG" -R "$GITHUB_REPOSITORY" --draft --verify-tag \
            --title "myapp $TAG" --generate-notes
          gh release upload "$TAG" -R "$GITHUB_REPOSITORY" dist/*
          gh release edit "$TAG" -R "$GITHUB_REPOSITORY" --draft=false

Note:$TAG comes from github.ref_name, passed via env into the shell instead of being written directly into the script ${{ }} into the script—this is the module 6 habit for preventing script injection. --verify-tag Make sure the tag already exists, to avoid accidentally creating a tag at the head of the default branch. Split building and publishing into two jobs: only the publish job gets contents: write.

Lab 3: push a tag to trigger a Release and upload assets (about 7 min)

Enable immutable releases and add configuration: myapp → Settings → General → Releases → Enable release immutability (applies only to Releases created afterward). Commit the .github/release.yml and release.yml workflow to main. myapp needs a pyproject.toml before you can python -m build; if it does not have one, add a minimal version first (name, version, dependencies).
gh label create breaking-change -R $ORG/myapp -c B60205 2>/dev/null
gh label create ignore-for-release -R $ORG/myapp -c CCCCCC 2>/dev/null
git add .github pyproject.toml && git commit -m "ci: release workflow" && git push org main
Preview release notes (creates nothing):
gh api repos/$ORG/myapp/releases/generate-notes -f tag_name=v0.1.0 --jq .body | head -20
Push a signed tag to trigger publishing:
git tag -s v0.1.0 -m "v0.1.0"     # if signing is not set up, use -a
git push org v0.1.0
gh run watch -R $ORG/myapp $(gh run list -R $ORG/myapp -w release -L1 --json databaseId --jq '.[0].databaseId')
gh release view v0.1.0 -R $ORG/myapp
myapp v0.1.0
Immutable · Latest · github-actions released this less than a minute ago

  ## What's Changed
  * ci: release workflow by @YOUR-USER in #3
  **Full Changelog**: https://github.com/myorg-lab/myapp/commits/v0.1.0

Assets
myapp-0.1.0-py3-none-any.whl   6.12 KiB
myapp-0.1.0.tar.gz             5.40 KiB
SHA256SUMS                     184 B
Verify as an end user:
cd /tmp && gh release download v0.1.0 -R $ORG/myapp -p '*.whl' -p SHA256SUMS
sha256sum -c --ignore-missing SHA256SUMS
gh release verify v0.1.0 -R $ORG/myapp
gh release verify-asset v0.1.0 myapp-0.1.0-py3-none-any.whl -R $ORG/myapp
Experience immutability: gh release upload v0.1.0 README.md -R $ORG/myapp should be rejected; gh release edit v0.1.0 --notes "additional notes" -R $ORG/myapp succeeds (notes remain editable).

Case 1: multi-platform release of a CLI tool

Problem: A Go CLI had to publish binaries for 6 platforms, and users complained after the arm64 build was left out. Approach: Matrix build of 6 binaries → a summary job generates SHA256SUMS → attestations (module 5) → upload to a draft Release → publish only after verifying the asset count is 7. Limitation: With immutable releases enabled, verification must happen before publishing, because assets cannot be uploaded after publishing.

Case 2: release-please created a Release, but the build workflow was not triggered

Problem: On top of the release-please configuration from the Git course, the team wrote a separate on: release: types: [published] build workflow, but it was never triggered. Cause: release-please-action uses GITHUB_TOKEN by default, and events it produces do not trigger new workflows. Approach: checking in the same workflow steps.release.outputs.release_created , then continue building and uploading; or configure a GitHub App token for release-please (actions/create-github-app-token).

Case 3: a trust crisis caused by replaced assets

Problem: A maintainer's account for an open-source project was stolen, and the attacker replaced the installer in the latest Release. Approach: Enable immutable releases at the organization level, generate all assets in CI with build attestations attached; downstream users verify with gh release verify-asset and gh attestation verify a double check. Effect: Even if the account is compromised, published assets cannot be replaced, and a new malicious Release lacks an attestation signed by the trusted workflow.

Common errors and fixes

HTTP 403: Resource not accessible by integration (https://api.github.com/repos/…/releases)

Cause: the job's GITHUB_TOKEN does not have contents: write (the organization default is read-only).

Fix: declare permissions: contents: write on the release job.

tag v0.1.0 doesn't exist in the repo (gh release create --verify-tag)

Cause: the tag has not been pushed yet, or the workflow was triggered by a branch push, and github.ref_name is a branch name.

Fix: confirm the trigger is push: tags; first git push origin TAG.

HTTP 422: Validation Failed — already_exists (uploading assets)

Cause: an asset with the same name already exists. A regular Release can use --clobber; an immutable Release cannot be replaced after publishing.

Fix: handle it at the draft stage; if already published, publish a new version.

The on: release workflow did not run

Cause: the Release was created by GITHUB_TOKEN , which does not trigger a new run; or the event type was written as created but the Release was published from a draft (publishing a draft triggers published).

Fix: switch to a GitHub App token or merge into the same workflow; check types.

The auto-generated notes are empty or include PRs that should not be there

Cause: the previous Release was determined incorrectly (the first Release includes all history), or the PRs were not labeled.

Fix: use --notes-start-tag v1.3.0 to specify the starting point; add labels; use exclude to exclude bot authors.

Command-line questions
1. Create a draft Release for v1.4.0 starting from v1.3.0, generate notes automatically, and upload all files under dist.
gh release create v1.4.0 dist/* --draft --verify-tag --generate-notes --notes-start-tag v1.3.0
2. Download v1.4.0's SHA256SUMS, verify the local wheel, and then verify the release attestation.
gh release download v1.4.0 -p SHA256SUMS -p '*.whl'
sha256sum -c --ignore-missing SHA256SUMS
gh release verify v1.4.0
Scenario analysis
The team wants “after the Release PR is merged, publish automatically, and the published assets are tamper-proof and traceable to CI.” Design the pipeline.

release-please (see the Git course) maintains the Release PR on main; after merging, in the same workflow release_created == true when it is: build assets → actions/attest generate attestations (module 5) → upload to a draft Release → publish. Immutable releases are enabled for the repository; a tag ruleset blocks manual tag creation v* (set a bypass for the App used by release-please); downstream users verify with gh release verify-asset and gh attestation verify .

Verified instructional videos

▶
AUTOMATED Release Notes - GitHub Checkout — GitHub
English · official channel demo of automatically generated release notes and release.yml categories
▶
Automated GitHub release with Release Please GitHub action — Ana's Dev Scribbles
English · automated publishing with release-please (for configuration details, see the Git course and the v5 docs)

Official documentation

Video storyboard (about 70 seconds)

Shot 1 · 0–20s
Visual: a tag is placed on a commit like a bookmark, and a Release is a box with notes and files attached to the bookmark.
Narration: tags belong to Git; Releases belong to GitHub.
Shot 2 · 20–45s
Visual: a draft box is opened, assets are placed inside one by one, and finally a lock is closed.
Narration: with immutable releases enabled, create a draft, add all assets, then publish. After publishing, the box is locked.
Shot 3 · 45–70s
Visual: a user downloads a file, and the terminal shows verified.
Narration: users can run gh release verify to confirm the file is the exact one that was originally published.
or score 70% or more on the quiz

Module 4 · GitHub Packages and GHCR

22:00 – 29:00 · ghcr.io is an OCI image registry at the organization or personal account level: permissions can be inherited from the repository or set independently; push from workflows with GITHUB_TOKEN
7 minpackages: writeOnce public, a package cannot be changed back to private★★★★
Learning goals
  • Log in and push in a workflow using GITHUB_TOKEN (packages: write), and use a classic PAT or gh token locally to pull and push ghcr.io/OWNER/IMAGE.
  • Understand the linkage (org.opencontainers.image.source tag, or automatic linking when publishing from a workflow),permission inheritance (inherits access permissions but not visibility), and Manage Actions access.
  • Use buildx to build linux/amd64 + linux/arm64 multi-architecture images, and read manifest lists (image indexes).
  • Use actions/delete-package-versions to safely clean up old versions without accidentally deleting multi-architecture child manifests and attestations.
Prerequisites: Images, tags, and digests from the Docker course. Importance:★★★★

What: GitHub Packages and the Container registry

GitHub Packages is a set of package registries: npm, Maven, Gradle, NuGet, RubyGems, and Container registry (ghcr.io). The old Docker registry (docker.pkg.github.com) has been replaced by ghcr.io. ghcr.io supports fine-grained permissions: images belong to a personal account or an organization (ghcr.io/myorg-lab/myapp), and can be linked to a repository or not.

Why: why use GHCR

  • It uses the same identity system as your code: push with GITHUB_TOKEN , with no separate registry password to manage; the token expires when the job ends.
  • Public images can be pulled anonymously, and public packages are free in GitHub Packages; Container registry storage and bandwidth are currently free (the official commitment is to give at least one month's notice before changes). Other package types for private packages are billed against plan quotas (Free: 500MB storage / 1GB bandwidth); see the billing docs for details.
  • Integrates naturally with artifact attestations: attestations can be pushed to GHCR alongside the image (module 5).

How: authentication and permissions

ScenarioCredentialKey points
A workflow pushes images linked to this repositoryGITHUB_TOKEN + permissions: packages: writeWhen publishing from a workflow, the repository is linked automatically and the workflow gets the admin role for that package
A workflow pulls other private packagesGITHUB_TOKEN (packages: read)you need to, in the package settings → Manage Actions access , add that repository as Read
Local developerspersonal access token (classic): read:packages / write:packages / delete:packagesGitHub Packages only supports classic PATs (fine-grained PATs are not supported); ticking the web option write:packages automatically ticks the broader repo, so use https://github.com/settings/tokens/new?scopes=write:packages to select only package permissions
Anonymousnonepublic packages only

Linking and inheritance (most confusing)

  • Link: add LABEL org.opencontainers.image.source=https://github.com/myorg-lab/myapp in the Dockerfile, or publish from a workflow in that repository with GITHUB_TOKEN .
  • Inheritance: for packages published after linking the repository first, access defaults to inheriting the linked repository's access permissions (people with read access to the repository also get read access to the package, and the repository's workflows automatically have access); but visibility is not inherited —a package published for the first time defaults to private private. If the package is linked after publishing, in package settings, inheritance does not happen automatically. Organization owners can turn off automatic inheritance.
  • Visibility: public / private (enterprises also have internal). Once changed to public, it cannot be changed back to private. An organization can use Settings → Packages → Package Creation to restrict which visibility members may choose for new packages.
  • Namespace conflicts: if a package with the same name was previously pushed from the command line without a linked repository, the GITHUB_TOKEN in the workflow will lack push permission— you need to link the repository in the package settings and grant Actions write access first.

Multi-architecture images

A multi-architecture image is an image index (manifest list), which lists the manifest of each platform image along with its digest; clients pick the one matching their platform when pulling. Build approaches: ① QEMU emulation + buildx builds all platforms on one amd64 runner (simple, but arm64 compilation is slower); ② native runner matrix (for example, a ubuntu-24.04-arm, usable with public repositories) builds each platform separately, then merges them with docker buildx imagetools create (fast, slightly more complex configuration; for arm64 hosted runner availability and billing in private repositories, follow the docs).

When: cleaning up old versions

Every push creates a new “version” (identified by digest; tags are just pointers). Use actions/delete-package-versions (v5,package-type: container) to clean up periodically. Warning: per-platform child manifests of multi-architecture images, and the attestations/signatures pushed with the image, all appear in GHCR as untagged versions; deleting them directly with delete-only-untagged-versions: true may remove child manifests that are still referenced by an index, causing pulls of that tag to fail. In production, either delete only “keep the most recent N”, or use a cleanup tool that recognizes index reference relationships, and rehearse first on a test package.

Common misconceptions① “The repository is public, so the image is naturally public”—visibility is not inherited; the first publish defaults to private. ② “A fine-grained PAT can also push to GHCR”—currently only classic PATs and GITHUB_TOKEN are supported. ③ “The latest tag was overwritten, so the old image is gone”—the old version still exists and just becomes an untagged version, taking up storage until deleted. ④ “Deleting untagged versions is always safe”—multi-architecture child manifests and attestations are also untagged versions.

Permissions diagram: packages, repositories, and workflows

Repository myorg-lab/myappMembers: dev team writeWorkflow: GITHUB_TOKENpackages: write Package ghcr.io/myorg-lab/myapp source label → link myapp Inherited access: inherits repository permissions Visibility: set independently (default private) Manage Actions access: myapp = Admin (automatic) deploy-repo = Read (added manually) Version: sha256:… tags v0.1.0, latest Untagged: child manifests / attestations / old versions Repository deploy-repoGITHUB_TOKEN packages: read Developer's local machineclassic PATread/write:packages Anonymous usersonly when the package is public(cannot be changed back after going public) push pull
Figure 4-1: what is inherited is access permissions, not visibility; reading across repositories requires Manage Actions access

Structure diagram: multi-architecture image index

ghcr.io/myorg-lab/myapp:v0.1.0→ image index sha256:9a1f… linux/amd64 manifest sha256:3c7e…config + layers linux/arm64 manifest sha256:b04d…config + layers attestation manifest (optional)buildx provenance / actions/attest On the GHCR package page, the two platform manifests and the attestation all show as “untagged versions”
Figure 4-2: one tag → one index → multiple platform manifests

Interactive builder: how multi-architecture images are built and pulled

Choose the target platforms and build approach, click “Build and push”, and observe the per-platform manifests and the image index generated by buildx; then choose a client platform and click “Pull” to see how the registry returns the matching manifest. Times are illustrative.

Target platforms
Build approach
Ready.

Core commands

CommandPurposeNotes
gh auth token | docker login ghcr.io -u USER --password-stdinLog in to GHCR locallythe gh token needs write:packages
docker buildx build --platform linux/amd64,linux/arm64 -t … --push .Build and push multi-architecture imagesmulti-platform results cannot be --load loaded into the local classic image store (unless the containerd image store is enabled)
docker buildx imagetools inspect IMAGEView the index and per-platform digests--format '{{json .Manifest}}'
docker buildx imagetools create -t TAG IMG@sha256:a IMG@sha256:bMerge natively built platform imagesnative matrix approach
gh api /orgs/ORG/packages/container/NAME/versionsList package versionsrequires read:packages
gh api -X DELETE /orgs/ORG/packages/container/NAME/versions/IDDelete a versionrequires delete:packages and package admin

Workflow: build and push multi-architecture images to GHCR

name: publish-image
on:
  push:
    branches: [main]
    tags: ["v*.*.*"]
permissions: {}
jobs:
  image:
    runs-on: ubuntu-24.04
    permissions:
      contents: read
      packages: write
    steps:
      - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
        with:
          persist-credentials: false
      - uses: docker/setup-qemu-action@99012661954931238ded8c8b007157a8430204e1 # v4.4.0
      - uses: docker/setup-buildx-action@f87e5991a6d7451dcb8d9637bfbc97413f497069 # v4.4.1
      - uses: docker/login-action@8aa5831fb8d48d8f76594c7ddde61ae58019f550 # v4.8.0
        with:
          registry: ghcr.io
          username: ${{ github.actor }}
          password: ${{ secrets.GITHUB_TOKEN }}
      - id: meta
        uses: docker/metadata-action@dc802804100637a589fabce1cb79ff13a1411302 # v6.2.0
        with:
          images: ghcr.io/${{ github.repository }}      # metadata-action lowercases the name
          tags: |
            type=semver,pattern={{version}}
            type=semver,pattern={{major}}.{{minor}}
            type=sha
            type=raw,value=latest,enable={{is_default_branch}}
      - id: push
        uses: docker/build-push-action@c3c9e263c25d99ce0380d002d59b67737d91b0dc # v7.4.0
        with:
          context: .
          platforms: linux/amd64,linux/arm64
          push: true
          tags: ${{ steps.meta.outputs.tags }}
          labels: ${{ steps.meta.outputs.labels }}
          annotations: ${{ steps.meta.outputs.annotations }}
          cache-from: type=gha
          cache-to: type=gha,mode=max
    outputs:
      digest: ${{ steps.push.outputs.digest }}

How to verify:docker buildx imagetools inspect ghcr.io/myorg-lab/myapp:latest shows two platforms. Notes: The metadata generated by metadata-action labels already includes org.opencontainers.image.source (pointing to the current repository), so the first publish links the repository; annotations makes the multi-architecture image show a description on the package page. steps.push.outputs.digest is the digest of the index, which module 5 uses to generate attestations.

Cleanup: keep the most recent 20 versions

name: ghcr-cleanup
on:
  schedule: [{cron: "17 3 * * 0"}]
  workflow_dispatch:
permissions: {}
jobs:
  prune:
    runs-on: ubuntu-24.04
    permissions:
      packages: write
    steps:
      - uses: actions/delete-package-versions@e5bc658cc4c965c472efe991f8beea3981499c55 # v5.0.0
        with:
          package-name: myapp
          package-type: container
          min-versions-to-keep: 20
          ignore-versions: '^v\d+\.\d+\.\d+$'     # never delete semantic versions (matched by version name; follow the README)

The repository needs a Admin role on the package (automatically granted to packages published from that repository's workflows). The ability for workflows to delete/restore packages via the REST API is currently in public preview. For the untagged-version issue with multi-architecture images and attestations, see “Theory”.

Lab 4: push amd64 + arm64 images and set visibility (about 7 min)

Try it locally first (confirm the Dockerfile supports multiple platforms):
gh auth token | docker login ghcr.io -u "$(gh api user --jq .login)" --password-stdin
docker buildx create --name multi --use 2>/dev/null || docker buildx use multi
docker buildx build --platform linux/amd64,linux/arm64 \
  --label org.opencontainers.image.source=https://github.com/$ORG/myapp \
  -t ghcr.io/$ORG/myapp:local-test --push .
docker buildx imagetools inspect ghcr.io/$ORG/myapp:local-test
Name:      ghcr.io/myorg-lab/myapp:local-test
MediaType: application/vnd.oci.image.index.v1+json
Digest:    sha256:9a1f…

Manifests:
  Name:        ghcr.io/myorg-lab/myapp:local-test@sha256:3c7e…
  Platform:    linux/amd64
  Name:        ghcr.io/myorg-lab/myapp:local-test@sha256:b04d…
  Platform:    linux/arm64
  Name:        ghcr.io/myorg-lab/myapp:local-test@sha256:77aa…
  Platform:    unknown/unknown
  Annotations:
    vnd.docker.reference.type: attestation-manifest

unknown/unknown is the provenance attestation manifest that buildx attaches by default (BuildKit's own SLSA provenance, which differs from the GitHub artifact attestation in module 5).

Commit publish-image.yml and run:
cd ~/src/myapp && git add .github/workflows/publish-image.yml
git commit -m "ci: publish multi-arch image to GHCR" && git push org main
gh run watch -R $ORG/myapp $(gh run list -R $ORG/myapp -w publish-image -L1 --json databaseId --jq '.[0].databaseId')
Check packages, linking, and visibility:
gh api /orgs/$ORG/packages/container/myapp --jq '{name, visibility, repository: .repository.full_name}'
gh api /orgs/$ORG/packages/container/myapp/versions --jq '.[] | {id, name, tags: .metadata.container.tags}' | head -20
{"name":"myapp","repository":"myorg-lab/myapp","visibility":"private"}
{"id":512345678,"name":"sha256:9a1f…","tags":["latest","sha-1a2b3c4"]}
{"id":512345671,"name":"sha256:3c7e…","tags":[]}
…
Change to public and pull anonymously: on the web, go to the package page → Package settings → Change visibility → Public (confirm the prompt: it cannot be changed back once public). Then, while logged out, pull the arm64 version:
docker logout ghcr.io
docker pull --platform linux/arm64 ghcr.io/$ORG/myapp:latest
docker image inspect ghcr.io/$ORG/myapp:latest --format '{{.Architecture}}'
arm64
Delete the version corresponding to the local test tag (delete only local-test this one index, to demonstrate the API):
VID=$(gh api /orgs/$ORG/packages/container/myapp/versions --jq '.[] | select(.metadata.container.tags | index("local-test")) | .id')
gh api -X DELETE /orgs/$ORG/packages/container/myapp/versions/$VID

Case 1: migrating from Docker Hub to GHCR

Problem: Docker Hub pull rate limits caused occasional CI failures, and team account passwords were scattered across the secrets of multiple repositories. Approach: Switch image pushes to GHCR, with the workflow using GITHUB_TOKEN; the deployment repository gets read-only access via Manage Actions access; delete all Docker Hub password secrets. Limitation: A Kubernetes cluster pulling private GHCR images still needs an imagePullSecret (a classic PAT or a bot account), or the image must be made public.

Case 2: exec format error on Graviton nodes

Problem: After arm64 nodes were added to EKS, some Pods reported exec /usr/local/bin/gunicorn: exec format error. Cause: the image was only built for amd64. Approach: Change the build to platforms: linux/amd64,linux/arm64; for services where arm64 compilation is very slow, switch to a native arm64 runner matrix + imagetools create.

Case 3: a cleanup script deleted the latest tag by mistake

Problem: To save space, a rule to “delete all untagged versions” was configured; the next day, pulling latest failed with manifest unknown. Cause: the platform sub-manifests referenced by the multi-architecture index are untagged versions in GHCR, and were deleted along with it. Approach: switch to keeping a fixed number of versions, and rehearse with a test package; afterward, rebuild and push the affected tags.

Common errors and fixes

denied: installation not allowed to Write organization package

Cause: the job is missing packages: write; or a package with the same name already exists but is not linked to this repository, or this repository is not Write/Admin in the package's Manage Actions access.

Fix: add the permission; link the repository in the package settings or add Actions access; before the first publish, add a org.opencontainers.image.source label to the image.

ERROR: failed to push ghcr.io/myorg-lab/MyApp:latest: invalid reference format: repository name must be lowercase

Cause:github.repository the name contains uppercase letters.

Fix: use metadata-action to generate the tags (it lowercases them), or convert in the shell with ${GITHUB_REPOSITORY,,} .

unauthorized: unauthenticated: User cannot be authenticated with the token provided.

Cause: a fine-grained PAT was used locally, the token expired, or the classic PAT lacks read:packages; when organization SAML SSO is enabled, the token is not authorized for SSO.

Fix: switch to a classic PAT and authorize SSO; or gh auth refresh -s read:packages.

docker exporter does not currently support exporting manifest lists

Cause: a multi-platform build used --load (or build-push-action's load: true).

Fix: for multi-platform builds use --push; for local single-platform testing, --platform linux/amd64 --load, or enable the containerd image store.

exec /bin/sh: exec format error (during the QEMU build stage)

Cause: QEMU binfmt is not installed (setup-qemu-action is missing), but a non-native platform is being built.

Fix: Before setup-buildx, add docker/setup-qemu-action, or switch to a native runner.

Command-line questions
1. List which platforms ghcr.io/myorg-lab/myapp:latest contains.
docker buildx imagetools inspect ghcr.io/myorg-lab/myapp:latest
2. List all version IDs and tags of the organization's container package myapp.
gh api --paginate /orgs/myorg-lab/packages/container/myapp/versions --jq '.[] | "\(.id) \(.metadata.container.tags|join(","))"'
Scenario analysis
deploy-repo's workflow reports denied when pulling myapp's private image, while myapp's own workflows push and pull normally. Why? How do you fix it with least privilege?

The package inherits the access permissions of the myapp repository, so myapp's workflows automatically have access; deploy-repo is not included. Fix: in package settings → Manage Actions access, add deploy-repo with the Read role; in deploy-repo's job, declare packages: read and log in with GITHUB_TOKEN . Do not create a long-lived PAT for this.

Verified instructional videos

▶
Introduction to GitHub Packages and GitHub Container Registry (GHCR) — CoderDave
English · GitHub Packages and GHCR concepts
▶
Push Docker Images to GitHub Container Registry — Brian Morrison
English · short video: push workflow demo
▶
GitHub Container Registry: BETTER Than Docker Hub? — CoderDave
English · GHCR vs. Docker Hub comparison

Official documentation

Video storyboard (about 80 seconds)

Shot 1 · 0–25s
Visual: a “link” line between the repository and the package; permissions flow along the line, but the “visibility” switch exists separately.
Narration: a package can inherit the repository's access permissions, but visibility must be set separately, and once public it cannot be changed back to private.
Shot 2 · 25–55s
Visual: one tag points to an index, which branches into amd64 and arm64 manifests; the arm64 client downloads only its own.
Narration: a multi-architecture image is a list of manifests, and clients pick by platform.
Shot 3 · 55–80s
Visual: a cleanup script sweeps through untagged versions; after a child manifest is accidentally deleted, latest turns red.
Narration: be careful when cleaning up—child manifests and attestations are also untagged versions.
or score 70% or more on the quiz

Module 5 · Artifact attestations and the supply chain (SLSA)

29:00 – 37:00 · The question an attestation answers is: “Which repository, which workflow, which commit, and on which runner was the artifact with this digest built?”
8 minactions/attest v4.2.2Private repositories require GHEC★★★★★
Learning goals
  • Use actions/attest to generate SLSA build provenance and SBOM attestations for binaries and container images, correctly declaring id-token: write,attestations: write and other permissions.
  • Explain the attestation generation chain: OIDC token → Sigstore Fulcio short-lived certificate → signed in-toto statement → transparency log (public repositories) → stored in the GitHub attestations API / pushed to the image registry.
  • Use gh attestation verify to verify, and use --signer-workflow,--source-ref,--deny-self-hosted-runners and similar options to tighten the policy.
  • Know that artifact attestations separately provide SLSA v1.0 Build L2, which, combined with reusable workflow builds, can reach Build L3; understand how they relate to cosign / Notation.
Prerequisites: Module 1 (reusable workflows), module 4 (image digests), and OIDC from Hours 3 and 4. Importance:★★★★★

What: what an artifact attestation is

An in-toto statement: subject (artifact name + SHA-256 digest) + predicate (assertions about it). actions/attest Three modes are supported:

ModeTrigger conditionpredicate
Provenance (default)not passed sbom-path / predicate inputgenerated automatically SLSA build provenance v1: build workflow, repository, ref, commit, triggering event, runner environment
SBOMpass sbom-path (SPDX or CycloneDX JSON, ≤16MB)SBOM content
Custompass predicate-type + predicate/predicate-pathcustom predicates (such as test reports or scan results)

Version notes (verified 2026-11-15): actions/attest v4.2.2 is the recommended entry point; actions/attest-build-provenance from v4 onward it is only its wrapper (latest v4.2.2), so old code can continue to be used; actions/attest-sbom (v4.1.0) is marked deprecated, migrating to actions/attest of sbom-path. Up to 1024 subjects per call.

Why: what else to prove beyond signing

Traditional signing only shows “whose private key signed this file”. Supply-chain attacks (SolarWinds, Codecov, tj-actions) often happen during the build: the source is fine, but the build environment is tampered with. Attestations bind the artifact to the build process: verifiers can require that only images built by myorg-lab/platform-workflows/.github/workflows/python-build.yml on GitHub-hosted runners, from refs/heads/main are accepted. The whole process requires no long-lived private key to manage—identity comes from the workflow's OIDC token.

How: generation chain

  1. After the job obtains id-token: write , the action actions/attest requests an ID token from the GitHub OIDC provider (audience sigstore), which contains repository,job_workflow_ref,sha,ref,runner_environment and other claims.
  2. The action generates an ephemeral key pair and hands the ID token to Fulcio (certificate authority). Fulcio verifies the token and issues a code-signing certificate valid for about 10 minutes, with the workflow identity written into the certificate extension fields.
  3. Signs the in-toto statement with DSSE using the ephemeral private key, which is then discarded.
  4. Public repositories: they use the public Sigstore instance, and signature records are written to a public, append-only transparency log Rekor; Private/internal repositories (requires GitHub Enterprise Cloud): they use GitHub's own Sigstore instance,no transparency log, and it federates only with GitHub Actions.
  5. The result is packaged as Sigstore bundle (certificate + signature + log/timestamp proof), uploaded to the repository's attestations API (indexed by subject digest, visible on the repository's Actions → Attestations page); push-to-registry: true for images, it is also pushed to the image registry as an OCI artifact; the local path is written to $RUNNER_TEMP/created_attestation_paths.txt.

Verification flow (gh attestation verify)

  1. computes the digest of a local file or oci:// image (the image must be accessible to resolve the digest).
  2. fetches the attestation by digest from the GitHub API (or uses a local file, or reads from the image registry with --bundle ,--bundle-from-oci for offline or isolated environments).
  3. uses the Sigstore trust root to verify the certificate chain, signature, and transparency log / timestamp (the certificate only needs to have been valid at signing time; expiry does not affect it).
  4. checks the identity in the certificate against the policy you provide: --owner or --repo (one is required),--signer-workflow/--signer-repo (where the build definition came from),--source-ref,--cert-oidc-issuer,--deny-self-hosted-runners; --predicate-type the default is SLSA provenance v1; when verifying an SBOM, specify it explicitly.

SLSA level

SLSA v1.0 Build levelRequirement (simplified)How GitHub meets it
L1Has build provenancegenerating provenance satisfies it
L2Hosted build platform + platform-signed provenanceartifact attestations alone provide Build L2 (GitHub-hosted runners + Sigstore signing)
L3Hardened build platform: builds are isolated from each other, signing material is not accessible to build steps, and provenance cannot be forgedin an organization-shared reusable workflow, building and attesting there keeps the build definition isolated from the caller; during verification, use --signer-workflow to pin that reusable workflow

Relationship with cosign / Notation

  • cosign (Sigstore project CLI, currently v3.1.4): the same Sigstore infrastructure. GitHub attestations use the standard Sigstore bundle format, so in theory they can be verified with Sigstore ecosystem tools; but gh attestation verify has GitHub's trust root and identity policies built in, and is the officially recommended approach. cosign can also sign images on its own in a workflow using keyless mode (cosign sign), and the two can coexist.
  • Notation (Notary Project): a signing scheme based on X.509 certificates and an organization-managed CA (often paired with Azure Key Vault / ACR), a separate system from Sigstore. GitHub attestations do not produce Notation signatures; if the deployment side (such as AKS + Ratify) only trusts Notation, you need extra signing.
  • Kubernetes enforcement: GitHub's documentation describes how to verify GitHub attestations with Sigstore policy-controller at cluster admission time (including configuring the GitHub trust root).

Scope

all current GitHub plans for public repositories are supported; private/internal repositories on Free / Pro / Team plans are not supported (GitHub Enterprise Cloud required); GitHub Enterprise Server is not supported; legacy Bronze/Silver/Gold plans are not supported.

Common misconceptions① “Having an attestation proves the code is safe”—an attestation only proves the origin, not that there are no vulnerabilities or malicious code. ② “Verifying with only --owner is enough”—any repository and any workflow in the organization (including compromised ones) can produce attestations that match the owner; in production, add --signer-workflow and --source-ref. ③ “The provenance built into buildx is the GitHub attestation”—BuildKit's provenance is not signed with a GitHub identity and cannot be verified with gh attestation verify . ④ “Verifying an image by tag”—attestations are bound to the digest, and tags can move.

Architecture diagram: attestation generation and verification

GitHub Actions job build → digest sha256:9a1f…actions/attest@v4id-token: writeattestations: writeGenerate ephemeral key pair GitHub OIDCID token (aud sigstore) Fulcio CA~10-minute code-signing certificate Rekor transparency logpublic repositories only Attestations APIbundle indexed by digest GHCR (optional)push-to-registry ① ② token + public key ④ ③ gh attestation verify oci://ghcr.io/myorg-lab/myapp:v0.1.0 --owner myorg-lab --signer-workflow …/python-build.yml 1 resolve image digest2 fetch bundle by digest3 verify certificate chain / signature / log4 verify identity policy (owner, workflow, ref, runner) Any step fails → non-zero exit code; the deployment pipeline / admission controller rejects the artifact
Figure 5-1: no long-lived private key: identity comes from OIDC, certificates are short-lived, and trust comes from the transparency log and the GitHub trust root

Comparison diagram: build topology for SLSA Build L2 vs. L3

L2: the application repository's own workflow builds and attests signer workflow = myorg-lab/myapp/.github/workflows/ci.yml The application team can change the build steps and the attestation steps too Verify with: --repo myorg-lab/myapp L3: calls an organization-shared reusable workflow signer workflow = myorg-lab/platform-workflows/…/python-build.yml Build and attestation logic is maintained by the platform team; the caller can only pass inputs Verify with: --repo myorg-lab/myapp --signer-workflow myorg-lab/platform-workflows/.github/workflows/python-build.yml
Figure 5-2: the certificate records both the “calling repository” and the “reusable workflow actually executed”

Core animation: generating and verifying build attestations (OIDC → Sigstore → storage → gh attestation verify)

First choose the repository visibility and click “Generate attestation” to step through the process; then choose an “attack / error” scenario, click “Verify”, and see gh attestation verify at which step it fails.

OIDC ID token Fulcio certificate DSSE signature Rekor record Attestations API GHCR referrer Resolve digest Fetch bundle Cryptographic check Identity policy check
Click “Generate attestation”.

Core commands

CommandPurposeNotes
gh attestation verify FILE -R OWNER/REPOVerify a local artifactor --owner ORG
gh attestation verify oci://IMAGE:TAG --owner ORGverify an imagerequires access to the image registry
--signer-workflow O/R/.github/workflows/f.ymlpin the workflow that signed itkey for L3 verification
--source-ref refs/heads/mainrestrict the build source branch/tagreject artifacts built from feature branches
--deny-self-hosted-runnersreject artifacts built on self-hosted runners
--predicate-type https://spdx.dev/Document/v2.3Verify an SBOM attestationonly verifies SLSA provenance v1 by default
--format json --jq '.[].verificationResult.statement.predicate'View attestation contents
gh attestation download FILE -R O/R / gh attestation trusted-rootPreparing for offline verificationTogether with --bundle,--custom-trusted-root

workflow: image provenance + SBOM attestations

    permissions:
      contents: read
      packages: write            # push images and push-to-registry
      id-token: write            # request a certificate from Sigstore
      attestations: write        # write to the attestations API
      artifact-metadata: write   # create storage records in the organization repository (with push-to-registry)
    steps:
      # …checkout / login / build-push (id: push) same as module 4…
      - name: Attest build provenance
        uses: actions/attest@1e69f48acb82d1966a394da916b4c1698aa569d6 # v4.2.2
        with:
          subject-name: ghcr.io/${{ github.repository }}     # do not include a tag; must be all lowercase
          subject-digest: ${{ steps.push.outputs.digest }}
          push-to-registry: true
      - name: Generate SBOM
        uses: anchore/sbom-action@fffec3d851af758d56fee099cf3fbf8aa8779843 # v0.24.3
        with:
          image: ghcr.io/${{ github.repository }}@${{ steps.push.outputs.digest }}
          format: spdx-json
          output-file: sbom.spdx.json
      - name: Attest SBOM
        uses: actions/attest@1e69f48acb82d1966a394da916b4c1698aa569d6 # v4.2.2
        with:
          subject-name: ghcr.io/${{ github.repository }}
          subject-digest: ${{ steps.push.outputs.digest }}
          sbom-path: sbom.spdx.json
          push-to-registry: true

artifact-metadata: write from the actions/attest README (2026-11): push-to-registry creates a “storage record” by default (organization repositories only; can be turned off with create-storage-record: false ), viewable on the organization's Linked Artifacts page. If the github.repository contains uppercase letters,subject-name convert it to lowercase first.

Verification

gh attestation verify oci://ghcr.io/myorg-lab/myapp:latest \
  --repo myorg-lab/myapp \
  --signer-workflow myorg-lab/platform-workflows/.github/workflows/python-build.yml \
  --source-ref refs/heads/main \
  --deny-self-hosted-runners
Loaded digest sha256:9a1f… for oci://ghcr.io/myorg-lab/myapp:latest
Loaded 1 attestation from GitHub API

The following policy criteria will be enforced:
- Predicate type must match:................ https://slsa.dev/provenance/v1
- Source Repository Owner URI must match:... https://github.com/myorg-lab
- Source Repository URI must match:......... https://github.com/myorg-lab/myapp
- Source repository ref must match:......... refs/heads/main
- Subject Alternative Name must match regex: (?i)^https://github.com/myorg-lab/platform-workflows/.github/workflows/python-build.yml
- OIDC Issuer must match:................... https://token.actions.githubusercontent.com
- Action workflow Runner Environment must match: github-hosted

✓ Verification succeeded!

The following 1 attestation matched the policy criteria
- Attestation #1
  - Build repo:..... myorg-lab/myapp
  - Build workflow:. .github/workflows/ci.yml@refs/heads/main
  - Signer repo:.... myorg-lab/platform-workflows
  - Signer workflow: .github/workflows/python-build.yml@refs/tags/v1

Lab 5: generate and verify attestations for an image (about 8 min)

Add attestations to the shared workflow: edit the python-build.yml of platform-workflows: the build job's permissions add id-token: write,attestations: write,artifact-metadata: write, and after build-push add the three steps from the “Commands” page (run only when inputs.push is true: if: inputs.push). Push a new tag:
cd ~/src/platform-workflows
git commit -am "feat: attest provenance and SBOM" && git push
git tag -a v1.1.0 -m v1.1.0 && git tag -f v1 && git push origin v1.1.0 && git push -f origin v1
grant the corresponding permissions in the calling job (otherwise the module 1 rule “permissions can only be lowered, not raised” will make the run fail at startup): myapp's ci.yml calling job:
    permissions:
      contents: read
      packages: write
      id-token: write
      attestations: write
      artifact-metadata: write
cd ~/src/myapp && git commit -am "ci: grant attestation permissions" && git push org main
gh run watch -R $ORG/myapp $(gh run list -R $ORG/myapp -w ci -L1 --json databaseId --jq '.[0].databaseId')
View attestations: on the web, go to myapp → Actions → Attestations; or from the command line:
DIGEST=$(docker buildx imagetools inspect ghcr.io/$ORG/myapp:latest --format '{{json .Manifest}}' | jq -r .digest)
gh api repos/$ORG/myapp/attestations/$DIGEST --jq '.attestations | length'
verify provenance and SBOM against the L3 policy:
gh attestation verify oci://ghcr.io/$ORG/myapp:latest --repo $ORG/myapp \
  --signer-workflow $ORG/platform-workflows/.github/workflows/python-build.yml
gh attestation verify oci://ghcr.io/$ORG/myapp:latest --repo $ORG/myapp \
  --predicate-type https://spdx.dev/Document/v2.3 --format json \
  --jq '.[0].verificationResult.statement.predicate.packages | length'
Trigger a verification failure: rebuild locally and push a tag with the same name (simulating an attacker overwriting latest), then verify again:
docker buildx build --platform linux/amd64 -t ghcr.io/$ORG/myapp:latest --push .
gh attestation verify oci://ghcr.io/$ORG/myapp:latest --repo $ORG/myapp
Loaded digest sha256:e41b… for oci://ghcr.io/myorg-lab/myapp:latest
✗ Loading attestations from GitHub API failed

Error: no attestations found for subject sha256:e41b…

Conclusion: in deployment, reference the image by digest, and verify before deploying. After the lab, re-run CI to restore latest.

Case 1: mandatory verification before deployment

Problem: An audit requires that “production only runs images built by a trusted pipeline.”Approach: The deployment workflow runs kubectl set image before gh attestation verify oci://…@sha256:… --owner org --signer-workflow org/platform-workflows/.github/workflows/build.yml --source-ref refs/heads/main --deny-self-hosted-runners, and stops on failure. On the cluster side, Sigstore policy-controller adds a second admission check. Limitation: Private repositories require GHEC; verification needs access to the GitHub API (for offline environments, use --bundle + trusted-root).

Case 2: downstream verification for an open-source CLI

Problem: Users download binaries from the Release page and cannot tell whether they were replaced. Approach: The release workflow generates subject-path: dist/* provenance for all binaries, and the README provides gh attestation verify ./tool -R org/tool; combined with immutable releases. Effect: Attestations for public repositories are also recorded in the public Rekor log, so anyone can audit them.

Case 3: the risk of verifying only with --owner

Problem: A company verified only with --owner . An attacker built a malicious image in a low-privilege experimental repository inside the organization, and it passed verification as well. Approach: Add --signer-workflow to pin the platform team's reusable workflow, and protect the platform-workflows repository with a ruleset (module 7).

Common errors and fixes

Error: Unable to get ACTIONS_ID_TOKEN_REQUEST_URL env variable

Cause: the job is missing id-token: write; or in a fork PR's pull_request run (it cannot obtain an OIDC token).

Fix: declare the permissions; run the attestation steps only on trusted events such as push / tag / release.

Error: Failed to persist attestation: Resource not accessible by integration

Cause: missing attestations: write; or the private repository is not on a GHEC plan.

Fix: add the permission; Free/Team private repositories cannot use this—switch to a public repository or upgrade.

✗ Verification failed — expected SourceRepositoryOwnerURI to be https://github.com/other-org

Cause:--owner/--repo it does not match the repository that actually built it; or the image came from a fork.

Fix: check the --format json build repo in the output; if the policy is wrong, correct the policy; if the source is wrong, reject the artifact.

no attestations found for subject sha256:…

Cause: the tag was re-pushed (the digest changed); the attestation subject used a platform child manifest instead of the index digest; or the attestation was written to another repository (the -R argument was wrong during verification).

Fix: verify by digest; when attesting, use the output of build-push-action; digest confirm the build repository.

expected SAN to match regex …platform-workflows… but was …/myapp/.github/workflows/ci.yml

Cause: the attestation was generated by the application repository's own workflow, so it does not satisfy the --signer-workflow policy.

Fix: run building and attesting in the shared reusable workflow; confirm that the caller actually went through the shared workflow.

Command-line questions
1. Verify that the local dist/myapp-0.1.0-py3-none-any.whl was built by myorg-lab/myapp and comes from the v0.1.0 tag.
gh attestation verify dist/myapp-0.1.0-py3-none-any.whl -R myorg-lab/myapp --source-ref refs/tags/v0.1.0
2. Prepare offline verification material for an isolated network environment.
gh attestation download dist/app.tar.gz -R myorg-lab/myapp     # generates sha256:….jsonl
gh attestation trusted-root > trusted_root.jsonl
# in the isolated environment:
gh attestation verify dist/app.tar.gz -R myorg-lab/myapp --bundle sha256-….jsonl --custom-trusted-root trusted_root.jsonl
Scenario analysis
The security team asks: “We already sign images with cosign. Do we still need GitHub artifact attestations?” How would you answer?

It depends on what the signature answers. cosign keyless signing is also based on Sigstore and OIDC identity, so in essence it can also prove “which workflow signed it”; GitHub attestations additionally provide standardized SLSA provenance content (build parameters, source commit, runner environment), storage and retrieval integrated with the GitHub API/UI,gh attestation verify built-in policies, and SBOM attestations. The two can coexist: existing cosign verification paths (such as Kyverno policies) stay as they are, and verification policies can gradually move to provenance content (signer workflow, source ref). If the deployment side only supports Notation, Notation signatures are still needed.

Verified instructional videos

▶
Secure your cloud-native deployments with Artifact Attestations — GitHub
English · official channel: image attestations and deployment verification (action names follow v4 in this lesson)
▶
What is sigstore? The future of supply chain security? — Cloud Native Skunkworks
English · Fulcio / Rekor / cosign basics
▶
SLSA, SigStore, SBOM & Software Supply Chain Security. What does it all mean? - Abdel Sghiouar — NDC Conferences
English · overview talk on concepts

Official documentation

Video storyboard (about 90 seconds)

Shot 1 · 0–20s
Visual: an image box has a digest label on it, with a “birth certificate” beside it.
Narration: the attestation states where the artifact with this digest came from and who built it.
Shot 2 · 20–50s
Visual: the runner takes an OIDC token to Fulcio and exchanges it for a certificate valid for 10 minutes; after signing, the certificate is discarded and the signature record enters the Rekor ledger.
Narration: there is no long-lived private key; identity comes from the workflow, and the signature record is written to a public ledger.
Shot 3 · 50–75s
Visual: a verifier checks off items one by one: digest, certificate chain, log, repository, workflow, branch, hosted runner.
Narration: verification does not only check that the signature is valid; it also checks whether a workflow you trust built the artifact.
Shot 4 · 75–90s
Visual: an attacker overwrites the latest tag, and verification shows “no attestations found”.
Narration: tags can be overwritten; digests and attestations do not lie.
or score 70% or more on the quiz

Module 6 · Actions security hardening

37:00 – 46:00 · A workflow is code that runs under your repository's identity: who can trigger it, whose code it runs, and how many permissions it gets—these three questions determine the cost of a compromise
9 mincheckout v7 blocks checkout of fork PRspull_request_target default policy enforced from 2026-12-02★★★★★
Learning goals
  • Use SHA pinning or workflow dependency lock files (gh actions-lock) to pin third-party actions, and keep them updated with Dependabot.
  • Default permissions: {}, grant least privilege per job; understand persist-credentials.
  • Explain pull_request_target / workflow_run the “pwn request” risk of, and the checkout v7 protections and GitHub's default event policy.
  • Identify and fix script injection: pass ${{ github.event.* }} through env env first, then reference it in the script.
  • Use zizmor and OpenSSF Scorecard to audit workflows, and be able to review the tj-actions/changed-files incident.
Prerequisites: Modules 1–5. Importance:★★★★★

What: the Actions threat model

Attack surfaceTypical techniqueProtection
Third-party actions / reusable workflowsA maintainer's account or token is stolen, and a tag is repointed to a malicious commit (tj-actions)SHA pinning or lock files; organization allowlists; fewer dependencies
Untrusted inputshell commands embedded in PR titles, branch names, or comments (script injection)pass expressions via env; use action inputs instead of inline scripts
Privileged triggers executing untrusted codepull_request_target checking out fork code and then npm install/make (pwn request)Switch to pull_request; checkout v7 blocks by default; Actions event policy
excessive token permissionsinjected steps use a write token to push code or modify Releasespermissions: {} + least-privilege permissions per job; organization default is read-only
leftover credentialslater steps or uploaded artifacts read the token saved by checkout (artipacked)persist-credentials: false; do not upload the entire workspace
cache poisoninga low-trust run writes to the cache, which a high-trust run then restorespull_request_target default-branch caches are read-only for other runs (GitHub default); zizmor cache-poisoning
self-hosted runnersfork PRs from public repositories execute on internal-network runnersdo not use self-hosted runners with public repositories; ephemeral runners; Hour 7

Pin dependencies: SHAs, lock files, and Dependabot

  • SHA pinning: uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1. A full 40-character SHA cannot be moved (forging one would require a SHA-1 collision with a valid object). Make sure the SHA belongs to the original repository, not a fork (zizmor's impostor-commit audit specifically checks this).
  • workflow dependency lock files (new in 2026, verified in the docs 2026-11): .github/workflows/actions.lock, generated by the GitHub CLI extension gh actions-lock (gh extension install github/gh-actions-lock). It records the commit SHA each action reference resolves to, plus the source repository's owner_id/repo_id,including transitive dependencies (actions used inside the actions you use). At runtime it verifies that the commit is reachable from the recorded tag or branch and that the repository identity has not changed. Official wording: repositories that adopt lock files no longer need to write SHAs in workflow files, and the lock file satisfies the organization's “SHA pinning required” policy. does not cover reusable workflow calls (jobs.<id>.uses; these must use a SHA or their own lock file in their repository), and also do not cover ./ local actions (it is recommended to change them to $/).
  • Dependabot: package-ecosystem: github-actions Dependabot will open upgrade PRs for tag and SHA pins (with # vX.Y.Z comments). However, Dependabot vulnerability alerts only apply to actions that use semantic versions, not to SHA-pinned actions—SHA-pinned repositories must rely on version-update PRs or zizmor known-vulnerable-actions to find vulnerable versions. zizmor also provides dependabot-cooldown audits; we recommend setting a cooldown period for updates to avoid pulling in a newly poisoned version right away.

Minimize permissions

Write permissions: {} at the top level of the workflow, then list only the permissions each job needs. Once a job declares permissions, anything unlisted becomes none. Common combinations: testing contents: read; pushing images packages: write; attestations id-token: write + attestations: write; publishing a Release contents: write; PR comments pull-requests: write; uploading SARIF security-events: write. actions/checkout Default persist-credentials: true (from v6 it is saved in $RUNNER_TEMP a separate file rather than .git/config, but later steps can still use it); jobs that do not need git push should set it to false.

pull_request_target and workflow_run

  • pull_request (fork PRs): runs the workflow in the PR merge commit, with a read-only token and no secrets—the safe default.
  • pull_request_target: runs the base repository's default branch workflows, with secrets and a writable token. It is safe in itself; the danger is when the author points actions/checkout to the PR head (ref: ${{ github.event.pull_request.head.sha }}) and then executes the checked-out code (building, testing, installing dependencies, reading its config files)—this is the “pwn request”.
  • workflow_run: runs with privileges after another workflow completes; if it downloads artifacts uploaded by a fork PR run and executes or trusts their contents, that is also a pwn request. Artifacts are untrusted data.
  • GitHub's new protections (2026, verified): ① actions/checkout starting from v7.0.0, for pull_request_target / workflow_run workflows triggered by , checkout denies fork PR code by default, and when truly needed, explicitly set allow-unsafe-pr-checkout: true (the name is deliberately conspicuous to aid review and static analysis); this protection does not cover git fetch,gh pr checkout, downloading artifacts, or other ways of fetching code. ② Default event policy in Actions policies: for public repositories without an applicable event policy, GitHub has added a default policy that blocks pull_request_target (currently in evaluate mode); from 2026-12-02 it will be enforced for affected repositories that used the default policy before GA; private/internal repositories are not affected. Repositories that need it must create an explicit event policy that allows pull_request_target . ③ pull_request_target Run-level caches are scoped to the default branch and read-only for other runs, preventing cache poisoning.

Script injection

run: : the ${{ … }} expressions in are text-substituted by the runner before the script file is generated, and the result is then handed to bash for execution. If the value comes from an attacker (PR title or body, branch name head_ref, commit message, comment, issue title, author name or email, and so on), it effectively lets the attacker write your script. Fix: put the expression into env: the env block, and in the script use "$VAR" to reference it—the value is then passed in as an environment variable, and bash treats it only as data. An even better approach is to pass the value as an with input to a JS action. GITHUB_ENV/GITHUB_OUTPUT Writing untrusted multi-line content is equally dangerous (zizmor github-env).

Audit tool

ToolWhat it doesverified 2026-11
zizmorstatic analysis of workflows / actions: template-injection,excessive-permissions,unpinned-uses,artipacked,dangerous-triggers,dangerous-checkout,cache-poisoning,secrets-inherit,impostor-commit,known-vulnerable-actions,dependabot-cooldown and 40+ other checks; can output SARIF to code scanningv1.32.0 (2026-11-02); zizmorcore/zizmor-action v0.8.1
OpenSSF Scorecardscores the repository's supply-chain practices (0–10): Dangerous-Workflow, Token-Permissions, Pinned-Dependencies, Branch-Protection, Code-Review, Signed-Releases, Dependency-Update-Tool, etc.ossf/scorecard-action v2.5.0
CodeQL (actions language)code scanning can also analyze injection and dangerous patterns in workflows (Hour 6)free for public repositories

Case review: tj-actions/changed-files (CVE-2025-30066 / GHSA-mrrh-fwg8-r2c3)

  • What happened: on 2025-03-14/15, attackers repointed multiple version tags of the action to a malicious commit; the malicious code read secrets from the Runner.Worker process memory on the runner and printed them in encoded form to the build logs—public repositories logs are readable by anyone, so a large number of secrets were exposed. Upstream investigation points to a chain of token leaks as the entry point (related to the same-period poisoning of reviewdog/action-setup , CVE-2025-30154); follow the official advisory for details.
  • Impact: every repository that referenced it by a tag (such as @v45) executed the malicious code during that window; repositories pinned by SHA to an older commit were not affected (unless they happened to pin the malicious SHA). The fixed version is 46.0.1.
  • Lessons: ① mutable tags → SHA pinning / lock files; ② public logs → even when secrets are masked, encoded values can still leak, so all potentially exposed secrets must be rotated afterwards; ③ use the organization's allowlist ! syntax to quickly block an action; ④ use few niche third-party actions—if a few lines of shell or an official action can do the job, implement it yourself; ⑤ a Dependabot cooldown period prevents pulling in a malicious new version right away.
Common misconceptions① “Using the tag of an official action like @v4 is safe”—official actions carry low risk, but third-party action tags can be moved by anyone who gets write access. ② “Secrets are masked in logs, so they cannot leak”—masking only matches the raw value; encoded or split values are not recognized. ③ “pull_request_target is itself a vulnerability”—the danger is executing untrusted code inside it. ④ “Quoting the expression "${{ … }}" makes it safe”—an attacker can close the quotes first.

Comparison diagram: pull_request vs. pull_request_target

pull_request (fork PR) workflow comes from: the PR merge commit (attacker can modify) checkout by default: the PR merge commit GITHUB_TOKEN: read-only · secrets: none first-time contributors: approval needed to run ✓ safe to build and test untrusted code cost: no secrets, cannot write comments/labels pull_request_target workflow comes from: the base repository's default branch (trusted) checkout by default: the default branch (no PR code) GITHUB_TOKEN: writable · secrets: available cache: scoped read-only to the default branch ⚠ checking out the PR head and executing it = pwn request checkout v7 blocks by default · public-repository default event policy enforced from 2026-12-02 for blocking this event
Figure 6-1: security comes from “untrusted code only runs in an unprivileged context”

Flowchart: at which step script injection happens

run: echo "${{ github.event.pull_request.title }}" runner substitutes the expression as text(before the shell) writes /tmp/…shattacker content has become code bash -e executeswith the token and secrets env: TITLE: ${{ … }}run: echo "$TITLE" the expression is substituted only into envscript text unchanged bash expands "$TITLE" → a single string argumentquotes, semicolons, and $( ) are just data
Figure 6-2: substitute-then-execute is the root of injection; env keeps the value out of the “code” layer

Interactive simulator: script injection attack and defense

Enter a “PR title”, choose a workflow style, and click “Run”. The simulator shows the real runner order: expression substitution → the generated script file → the commands bash actually executes.

① Script file generated by the runner
② Commands actually executed by bash
Choose an example, then click Run.

Core commands and configuration

CommandPurposeNotes
git ls-remote https://github.com/OWNER/REPO refs/tags/vX.Y.ZLook up the SHA for a tagfor annotated tags, also check ^{} line
gh extension install github/gh-actions-lock → gh actions-lockGenerate a lock file--migrate-local-actions Pass ./ Change to $/
uvx zizmor .github/workflows/offline auditcan also be used pipx run zizmor,brew install zizmor
GH_TOKEN=$(gh auth token) uvx zizmor .enable online auditimpostor-commit, known-vulnerable-actions, ref-confusion
uvx zizmor --fix=safe .automatically fix some issuesavailability is determined by --help the installed version
scorecard --repo=github.com/ORG/REPOScorecard CLIrequires GITHUB_AUTH_TOKEN

a before-and-after comparison

on: pull_request_target
permissions: write-all
jobs:
  greet:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
        with:
          ref: ${{ github.event.pull_request.head.sha }}   # check out fork code
      - run: npm ci && npm test                           # running it = pwn request
      - run: echo "Thanks for ${{ github.event.pull_request.title }}"   # script injection
      - uses: tj-actions/changed-files@v45                 # mutable tag
on: pull_request                     # use pull_request if no secrets are needed
permissions: {}
jobs:
  test:
    runs-on: ubuntu-24.04
    permissions:
      contents: read
    steps:
      - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
        with:
          persist-credentials: false
      - run: npm ci && npm test
      - env:
          TITLE: ${{ github.event.pull_request.title }}
        run: echo "Thanks for $TITLE"
      - id: changed                     # compute with git itself, without depending on a third-party action
        env:
          BASE: ${{ github.event.pull_request.base.sha }}
        run: |
          git fetch --no-tags --depth=1 origin "$BASE"
          git diff --name-only "$BASE" HEAD > changed.txt

.github/dependabot.yml

version: 2
updates:
  - package-ecosystem: github-actions
    directory: /
    schedule:
      interval: weekly
    cooldown:
      default-days: 7          # open PRs only 7 days after a new version is released (follow the Dependabot docs for the field names)
    groups:
      actions:
        patterns: ["*"]

.github/workflows/audit.yml (zizmor + Scorecard)

name: audit
on:
  push:
    branches: [main]
  schedule: [{cron: "30 4 * * 1"}]
permissions: {}
jobs:
  zizmor:
    runs-on: ubuntu-24.04
    permissions:
      contents: read
      security-events: write       # upload SARIF to code scanning (free for public repositories)
    steps:
      - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
        with:
          persist-credentials: false
      - uses: zizmorcore/zizmor-action@45d7276c9ca790aabd705e31ca99c6185c3e76dd # v0.8.1
  scorecard:
    runs-on: ubuntu-24.04
    permissions:
      contents: read
      security-events: write
      id-token: write              # needed for publish_results
    steps:
      - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
        with:
          persist-credentials: false
      - uses: ossf/scorecard-action@46dc3187a971a9febf3aeb7f94ccde489f7bb46a # v2.5.0
        with:
          results_file: results.sarif
          results_format: sarif
          publish_results: true
      - uses: github/codeql-action/upload-sarif@v4   # in production, pin the SHA as well
        with:
          sarif_file: results.sarif

Lab 6: scan and fix myapp with zizmor (about 9 min)

Plant a deliberately dangerous “teaching” workflow (only on a branch of your own lab repository,do not merge): save the “dangerous patterns” from the “Commands” page as .github/workflows/bad.yml (you can scan without pushing).
Offline scan:
cd ~/src/myapp
uvx zizmor@1.32.0 .github/workflows/
error[dangerous-triggers]: use of fundamentally insecure workflow trigger
 --> .github/workflows/bad.yml:1:1
error[template-injection]: code injection via template expansion
 --> .github/workflows/bad.yml:11:14
warning[excessive-permissions]: overly broad permissions
 --> .github/workflows/bad.yml:2:1
error[unpinned-uses]: unpinned action reference
 --> .github/workflows/bad.yml:12:15
warning[artipacked]: credential persistence through GitHub Actions artifacts
 --> .github/workflows/bad.yml:6:9
…
N findings (…): X high, Y medium …
Online audit (checks for known-vulnerable versions and impostor commits):
GH_TOKEN=$(gh auth token) uvx zizmor@1.32.0 .github/workflows/bad.yml

should additionally show known-vulnerable-actions: tj-actions/changed-files@v45 is affected by GHSA-mrrh-fwg8-r2c3.

Fix: rewrite it using the “after hardening” pattern (or delete bad.yml directly), then scan until there are 0 high-severity findings. Generate a lock file for the real workflows:
rm .github/workflows/bad.yml
gh extension install github/gh-actions-lock
gh actions-lock --migrate-local-actions
git diff --stat; cat .github/workflows/actions.lock | head -20
uvx zizmor@1.32.0 .github/workflows/
Enable continuous auditing: commit dependabot.yml and audit.yml, then after running, check the zizmor and Scorecard results under Security → Code scanning:
git add .github && git commit -m "ci: dependabot, lockfile, zizmor and scorecard" && git push org main
gh api repos/$ORG/myapp/code-scanning/alerts --jq '.[] | "\(.tool.name)\t\(.rule.id)\t\(.state)"' | head

Case 1: incident response on the day of the tj-actions event

Problem: 40 of the company's 300 repositories used tj-actions/changed-files@v4x. Approach:① immediately add !tj-actions/changed-files@* to the organization allowlist to block it; ② use code search and referenced_workflows/run logs to find repositories that executed it during the incident window; ③ rotate all secrets accessible to those repositories (including organization-level secrets); ④ for public repositories, check whether encoded secrets appear in the logs; ⑤ switch to SHA pinning + a Dependabot cooldown period, or replace it with git commands. Lesson: SHA pinning beforehand is far cheaper than emergency response afterward.

Case 2: a pwn request in a labeling bot

Problem: An open-source project used pull_request_target to label PRs automatically; later someone added a checkout of the PR head plus npm ci to “run lint along the way”, and a malicious postinstall PR stole the npm publish token. Approach: Split into two workflows: pull_request run lint/test (no secrets); pull_request_target only call the API to apply labels, without checking out code. After upgrading to checkout v7, similar mistakes are blocked by default.

Case 3: branch name injection

Problem: In a workflow, run: ./deploy.sh ${{ github.head_ref }}, someone created a branch named a;curl${IFS}…|sh (branch names allow these characters). Approach: Change it to env: REF: ${{ github.head_ref }} + ./deploy.sh "$REF"; add zizmor blocking to CI template-injection.

Common errors and fixes

checkout fails in pull_request_target with: refusing to check out fork pull request code (allow-unsafe-pr-checkout)

Cause: checkout v7 blocks by default checking out fork PR code in pull_request_target/workflow_run workflows (follow the actual error text).

Fix: Preferably switch to pull_request; only if you confirm the code is only inspected as data and never executed, set allow-unsafe-pr-checkout: true, and add least-privilege permissions and pass no secrets.

Event 'pull_request_target' is not allowed to trigger Actions workflows. Workflow file: '.github/workflows/label.yml'.

Cause: an Actions policy (an event rule or the public-repository default policy) blocked the event.

Fix: Assess whether it is really needed; if so, a repository or organization administrator should create an explicit policy that allows this event in Settings → Actions → Policies; first observe the impact in evaluate mode with policy insights.

Error: Unable to resolve action `owner/repo@<sha>`, unable to find version `<sha>`

Cause: the SHA was copied wrong, a short SHA was used, or the commit exists only in a fork (impostor commit).

Fix: Use git ls-remote to fetch the full SHA again from the original repository; run zizmor online checks impostor-commit.

lockfile missing pin for octo-org/setup-tool@v2.0.0

Cause: the workflow is in the lock file, but the referenced action (or an action used inside a local action) has no lock entry.

Fix: Re-run gh actions-lock; for local actions, use --migrate-local-actions to change to $/.

Dependabot does not raise security alerts for SHA-pinned actions

Cause: According to the docs, Dependabot alerts only apply to actions referenced by semantic version.

Fix: keep # vX.Y.Z comments so Dependabot version updates work; run zizmor regularly known-vulnerable-actions.

Command-line questions
1. Find the full commit SHA for docker/login-action v4.8.0.
git ls-remote https://github.com/docker/login-action refs/tags/v4.8.0 'refs/tags/v4.8.0^{}'
2. Rewrite the script below in a safe way: run: echo "${{ github.event.issue.title }}" | ./triage.sh
- env:
    ISSUE_TITLE: ${{ github.event.issue.title }}
  run: printf '%s\n' "$ISSUE_TITLE" | ./triage.sh
Scenario analysis
A public repository needs to run integration tests on fork PRs, and the tests must access a private package repository (which requires a secret). How can this be done without introducing a pwn request?

Option 1: pull_request run the tests that need no secret; move the integration tests that need the secret to manual triggers after a maintainer reviews the PR (triggered by a label, or workflow_dispatch by specifying the PR number), and run them in a controlled environment (environment + required reviewers). Option 2: change the private dependencies to public mirrors or cached artifacts. Avoid: pull_request_target checking out the PR head and executing it. If you really must use pull_request_target, an explicit event policy must allow it,allow-unsafe-pr-checkout and you must ensure the code is never executed—this basically cannot satisfy the requirement to “run the tests”.

Verified instructional videos

▶
[FOSDEM 2025] Hunting for GitHub Actions bugs with zizmor — William Woodruff
English · how zizmor's author explains common workflow vulnerability categories
▶
Black Hat USA 2025 | Uncovering and Responding to the tj-actions Supply Chain Breach — Black Hat
English · discovering and responding to the tj-actions incident
▶
Implementing the OpenSSF Best Practices Badges & Scorecards Into Your Project - CRob & David Wheeler — The Linux Foundation
English · Scorecard and best-practice badges

Official documentation

Video storyboard (about 90 seconds)

Shot 1 · 0–25s
Visual: the v45 tag is peeled off like a sticky note and stuck onto a red commit; thousands of repositories turn red at once.
Narration: tags can be moved. In the tj-actions incident, attackers delivered malicious code into tens of thousands of pipelines this way.
Shot 2 · 25–55s
Visual: PR title text is “pasted” into a shell script, and a curl appears after a semicolon.
Narration: expressions are substituted before the shell runs, so an attacker's title becomes your script. Put it in env, and it is just data.
Shot 3 · 55–90s
Visual: zizmor outputs a column of red and yellow alerts; they turn green as each one is fixed, and a lock-file icon appears.
Narration: least privilege, pinned dependencies, and auditing tools—once these three are done, the cost of an attack rises dramatically.
or score 70% or more on the quiz

Module 7 · Organization-level governance: required workflows / rulesets

46:00 – 54:00 · Hardening of a single repository is easily forgotten; organization-level policy is not: enterprise → organization → repository tightens layer by layer, and lower layers can only be stricter
8 minThe allowlist can hold up to 1000 entriesLegacy required workflows have been replaced by rulesets★★★★
Learning goals
  • Configure the organization's allowed actions and reusable workflows policy (including ! block syntax and the “must pin SHA” option).
  • Set organization default GITHUB_TOKEN permissions, the toggle for PR creation/approval, and approval for fork PR runs.
  • Understand where legacy required workflows went: organization/enterprise rulesets with “Require workflows to pass before merging”; understand the Actions policy (workflow execution protection) added in 2026 Actions policies.
  • Manage repository access scope for organization secrets and variables, and access control for runner groups.
Prerequisites: Rulesets from the Git course, lesson 3; this lesson's modules 1 and 6. Importance:★★★★

What: the organization-level Actions control plane

ControlLocation (organization Settings)PurposePlan / notes (verified 2026-11)
Allowed actions and reusable workflowsActions → General → Policiesallow all / only this organization / this organization + selected (GitHub official, Marketplace verified creators, specified list)all plans; the specified list holds up to 1000 entries; “only this organization” also actions/checkout disables
Require actions to be pinned to a full-length commit SHAsame as aboveall actions (including official and this organization's) must use a full SHA; reusable workflows can still be referenced by tagworkflows included in a lock file satisfy this automatically
Workflow permissionsActions → GeneralDefault GITHUB_TOKEN: read/write for all (permissive) or read-only for contents/packages only (restricted); whether Actions can create or approve PRsnew organizations do not allow creating or approving PRs by default
Fork PR workflowsActions → Generalpublic repositories: which contributors need approval to run; private repositories: whether fork PRs run, whether they get write tokens or secrets, and whether approval is needed“Only first-time contributors need approval” can be bypassed by first merging a small change
Actions policies (workflow execution protection)Actions → Policies (separate from General)targeted by repository (visibility, deployment status, custom properties) and workflow path; Actor rules (who can trigger),Event rules (which events are allowed); Require lockfile protectionadded in 2026; three levels: enterprise / organization / repository; Evaluate mode is GHEC only; public repositories block by default pull_request_target (enforced from 2026-12-02)
Ruleset: Require workflows to pass before mergingRepository → Rulesets (organization level)for the target branches of target repositories, forces the specified workflow from a central repository to run and pass before mergingreplaces legacy required workflows; for plan requirements, follow the official docs (the GitHub blog says it applies to GHEC)
Organization secrets / variablesSecrets and variables → Actionsaccess policy: all repositories / private repositories / selected repositoriesPrivate repositories in a GitHub Free organization cannot use organization-level secrets/variables
Runner groupsActions → Runner groupscontrol which repositories (optionally which workflows) can use a group of self-hosted runnersEach organization has one default group; creating additional groups requires Team or above

Why: why organization-level control

Every hardening step in module 6 relies on “each repository maintainer remembering to do it.” Organization policy turns the key baseline into a mandatory requirement: even if a repository's workflow uses uses: random/action@main, it fails at startup because it is not on the allowlist; even if a maintainer forgets to write permissions , the default is read-only; and even if a repository deletes its own scanning workflow, the central workflow required by the ruleset still runs on PRs.

How: several key mechanisms

1. Allowlist matching syntax

  • actions: OWNER/REPO@TAG-OR-SHA, such as docker/login-action@*,actions/javascript-action@v1.0.1.
  • Reusable workflows: OWNER/REPO/PATH/FILENAME@REF, such as myorg-lab/platform-workflows/.github/workflows/python-build.yml@*.
  • Wildcards: myorg-lab/*; blocking: ! prefix, such as *, !tj-actions/changed-files@* (everything allowed but one action blocked). By default, only items on the list are allowed.
  • Workflows in a lock file match by the locked commit SHA matching: entries in the list actions/checkout@v6 such tag entries will not match locked dependencies; write actions/checkout@* or a full SHA.

2. Layering

Enterprise policy → organization policy → repository policy: lower layers can only tighten further within what the layer above allows (for example, the enterprise allows everything while the organization allows only a selected list; the organization sets a restricted token, and repositories cannot loosen it back). Actions policies and rulesets stack the same way: when several policies apply, any one that blocks will block.

3. Current state of required workflows

The 2023 Actions “required workflows” beta feature has been retired (the GHES docs explicitly state “GitHub no longer supports required workflows for GitHub Actions”); the replacement is organization/enterprise rulesets under Require workflows to pass before merging: in the ruleset, select a workflow file from a central repository (it can be pinned to a branch, tag, or SHA), and it runs on PRs in the target repositories. Key points: the required workflow only supports pull_request,pull_request_target,merge_group events (when using a merge queue, add merge_group); it does not run for GITHUB_TOKEN events triggered by; PRs opened before the rule was created need a new commit or a reopen to trigger it; the visibility of the repository containing the workflow determines which repositories it can apply to (public → all, internal → internal and private, private → private); in Evaluate mode it runs but does not block. In the UI, Actions → Policies can also scope a policy to “required workflows”.

4. Access scope for organization secrets

An organization secret can be scoped to All repositories,Private repositories,Selected repositories. It ties into module 1: only secrets the calling repository can see can be passed through secrets: inherit to a reusable workflow. Production credentials should be placed in environment secrets (with required reviewers and a deployment branch policy) rather than organization secrets; for cloud credentials, prefer OIDC (Hours 3 and 4).

5. Runner groups

Self-hosted runners registered to an organization join the default group. Team and above can create custom groups, restrict which repositories can access them, and further restrict them to “only selected workflows” (for example, allow only the deployment workflow in platform-workflows to use runners on the production network; follow the docs for details). By default, only private repositories can use runners in a group; public repositories must enable this explicitly—this prevents fork PRs from running on your internal machines.

Common misconceptions① “Allowing only this organization's actions is the safest”—it also actions/checkout disables

Layering diagram: the gates a workflow must pass before it starts

Eventpush / PR / dispatch Actions policiesactor / event rulesRequire lockfile fork PR approvalfirst-time contributors / outside collaborators allowed actionsenterprise ∩ organization ∩ repositorySHA pinning requirement GITHUB_TOKENdefault permissions ∩ workflow permissions secretsorganization access policy+ environment protection runnerrunner group access merge gateRuleset:require workflow to pass
Figure 7-1: if any gate rejects, the run does not start (or the PR cannot be merged)

Organization baseline sketch (myorg-lab)

Actions → GeneralAllowed: this organization + GitHub official + verified creators+ list: ossf/*, zizmorcore/*, anchore/sbom-action@*☑ SHA pinning requiredGITHUB_TOKEN: restricted (read-only) Rulesets (organization level)Target: all repositories · default branchrequire PR + 1 reviewrequire workflow: platform-workflows/.github/workflows/audit.yml@v1 Actions → Policiesevents: public repositories block pull_request_targetActor: deploy.yml can only be triggered by the SRE teamRequire lockfile (Evaluate first)secrets: selected repositories
Figure 7-2: three settings each control “what can be used”, “what must run”, and “who can run it on which events”

Interactive calculator: organization allowlist and SHA pinning policy

Set the organization policy, then click “Evaluate” to see the following uses: references, whether each one is allowed or blocked when the workflow starts, and why. Matching logic follows the docs: * wildcards,! blocking, GitHub official = actions/* and github/*, and reusable workflows are not subject to the SHA pinning requirement.

Specified list (comma- or newline-separated)

REST API and gh commands

CommandPurpose
gh api -X PUT orgs/ORG/actions/permissions -f enabled_repositories=all -f allowed_actions=selectedSet the allowed-actions policy to “selected”
gh api -X PUT orgs/ORG/actions/permissions/selected-actions --input sel.jsonSet the official / verified creators / pattern list
gh api -X PUT orgs/ORG/actions/permissions/workflow -f default_workflow_permissions=read -F can_approve_pull_request_reviews=falseDefault read-only token, and prohibit approving PRs
gh secret set NAME --org ORG --visibility selected --repos myapp,platform-workflowsRestrict an organization secret to repositories
gh variable set NAME --org ORG --visibility all --body VALUEOrganization variables
gh api orgs/ORG/actions/runner-groupsList runner groups
gh api orgs/ORG/rulesetsList organization rulesets
gh api orgs/ORG/actions/permissions --jq .sha_pinning_requiredView the SHA pinning requirement (field names follow the API docs)
{
  "github_owned_allowed": true,
  "verified_allowed": true,
  "patterns_allowed": [
    "ossf/scorecard-action@*",
    "zizmorcore/*",
    "anchore/sbom-action@*",
    "!tj-actions/changed-files@*"
  ]
}
export ORG=myorg-lab
gh api -X PUT orgs/$ORG/actions/permissions -f enabled_repositories=all -f allowed_actions=selected
gh api -X PUT orgs/$ORG/actions/permissions/selected-actions --input sel.json
gh api orgs/$ORG/actions/permissions/selected-actions
{"github_owned_allowed":true,"verified_allowed":true,"patterns_allowed":["ossf/scorecard-action@*","zizmorcore/*","anchore/sbom-action@*","!tj-actions/changed-files@*"]}

This organization's actions and reusable workflows are automatically allowed in “this organization + selected” mode. Whether the API accepts ! the blocking pattern and the field names for the SHA pinning requirement, please refer to the REST docs; when unsure, use the web settings.

Workflow required by the ruleset: platform-workflows/.github/workflows/audit.yml

name: org-audit
on:
  pull_request:
  merge_group:            # needed by repositories that use a merge queue
permissions:
  contents: read
jobs:
  zizmor:
    runs-on: ubuntu-24.04
    steps:
      - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
        with:
          persist-credentials: false
      - run: pipx run zizmor==1.32.0 --min-severity high .github/workflows/   # follow zizmor --help for options

Lab 7: configure a governance baseline for myorg-lab (about 8 min)

Allowlist + SHA pinning: use the API from the “Commands” page or the web (Settings → Actions → General) to set “this organization + selected”. On the web, tick Require actions to be pinned to a full-length commit SHA.
Verify blocking: on a new branch of myapp, add a workflow that uses tj-actions/changed-files@v46.0.1, push, then observe the run failing:
Error: tj-actions/changed-files@v46.0.1 is not allowed to be used in myorg-lab/myapp.
Actions in this workflow must be: within a repository owned by myorg-lab, created by GitHub, verified in the GitHub Marketplace, or matching the following: ossf/scorecard-action@*, zizmorcore/*, …

Then change a step that has a pinned SHA back to actions/checkout@v7, and observe the failure caused by the SHA pinning requirement (workflows already in the lock file are unaffected). Delete the branch after verifying.

Default token read-only + organization secret restricted to repositories:
gh api -X PUT orgs/$ORG/actions/permissions/workflow -f default_workflow_permissions=read -F can_approve_pull_request_reviews=false
echo -n "demo-value" | gh secret set DEMO_TOKEN --org $ORG --visibility selected --repos myapp
gh secret list --org $ORG
NAME        UPDATED         VISIBILITY
DEMO_TOKEN  less than a minute ago  Visible to 1 selected repository
(depending on plan) ruleset requires workflow: commit audit.yml to platform-workflows and tag it; in organization Settings → Repository → Rulesets → New branch ruleset: target myapp the default branch, check “Require workflows to pass before merging”, and add platform-workflows the .github/workflows/audit.yml. If this option is not available on your plan, use an alternative: call audit.yml as a reusable workflow in myapp, then set its check as a required status check in the ruleset.
Actions policy (Evaluate mode depends on plan): organization Settings → Actions → Policies → New policy: name no-prt-public, target “public repositories”, event rule disallowing pull_request_target. If Evaluate is available, observe insights in Evaluate first; otherwise go straight to Active (myapp does not use this event anyway).

Case 1: Actions baseline at a financial company

Problem: Regulation requires that “the build toolchain is controlled and changes are auditable.”Approach: At the enterprise level, only this enterprise + GitHub official + about 40 reviewed third-party actions are allowed (all @SHA entries, updated by the platform team via Dependabot PRs); SHA pinning is required and lock files are rolled out gradually (Require lockfile in Evaluate for one month first); the default token is read-only; the production deployment workflow is restricted to the SRE team via Actions policy actor rules. Limitation: Maintaining an allowlist has a cost and requires a clear request and review process.

Case 2: migrating from required workflows to rulesets

Problem: Organizations that had used the Actions required workflows beta lost mandatory scanning after the feature was retired. Approach: Move the same workflow configuration to the organization ruleset “Require workflows to pass before merging”, adding merge_group triggers; first confirm with Evaluate (GHEC) that nothing is wrongly blocked, then switch to Active. Note: PRs created by GITHUB_TOKEN (such as some bots) do not trigger the required workflow; for those bots, use a GitHub App token instead.

Case 3: organization secret over-sharing

Problem: An organization-level cloud credential visible to “All repositories” was printed to the logs by a workflow in a newly created lab repository. Approach: Cloud credentials were switched to OIDC (Hours 3/4); all remaining organization secrets were changed to Selected repositories and audited by repository custom properties; production secrets were moved to environment secrets with required reviewers.

Common errors and fixes

The action owner/repo@v1 is not allowed in myorg-lab/myapp because all actions must be from a repository owned by myorg-lab …

Cause: the organization/enterprise allowlist does not include the action (or it is ! blocked).

Fix: Request that the platform team add it to the list (with a security review), or switch to an allowed alternative. Repository admins cannot loosen organization restrictions at the repository level.

The action actions/checkout@v7 is not allowed … must be pinned to a full-length commit SHA

Cause: SHA pinning is required (follow the actual error text).

Fix: Change to a full SHA, or use gh actions-lock to include it in the lock file. Reusable workflows are not subject to this restriction.

Resource not accessible by integration (many workflows failed after the organization switched to a restricted token)

Cause: The workflow relied on the previously permissive default write permissions.

Fix: Explicitly declare permissions in the relevant jobs; before switching, use zizmor excessive-permissions/undocumented-permissions to audit.

The workflow required by the ruleset keeps showing “Expected — Waiting for status to be reported”

Cause: the workflow does not pull_request/merge_group trigger; the PR was opened before the rule was created; the PR was created by GITHUB_TOKEN ; the central repository's visibility is insufficient to apply to the target repository.

Fix: Add the trigger; push a new commit or reopen the PR; switch to an App token; adjust the central repository's visibility.

No runner matching the specified labels was found: self-hosted, prod

Cause: The runner group is not open to this repository (or this workflow); public repositories cannot use group runners by default.

Fix: Add the repository/workflow to the runner group; use self-hosted runners carefully with public repositories.

Command-line questions
1. Set the organization default GITHUB_TOKEN to read-only, and prohibit Actions from approving PRs.
gh api -X PUT orgs/myorg-lab/actions/permissions/workflow -f default_workflow_permissions=read -F can_approve_pull_request_reviews=false
2. Create an organization secret NPM_TOKEN visible only to the myapp and api repositories.
gh secret set NPM_TOKEN --org myorg-lab --visibility selected --repos myapp,api
Scenario analysis
The platform team wants: ① every PR in every repository must pass the organization security scan; ② production deployments can only be triggered by SRE; ③ no unreviewed third-party actions are allowed. Which mechanism should be used for each?

① an organization ruleset “Require workflows to pass before merging” (pointing to the scanning workflow in platform-workflows, including merge_group); ② Actions policy actor rules (scoped to the deployment workflow path) + environment required reviewers; ③ set allowed actions to “this organization + GitHub official + specified list”, where the specified list contains only reviewed actions, and enable the SHA pinning requirement or Require lockfile.

Verified instructional videos

▶
GitHub Actions Policy Update: Blocking & SHA Pinning Explained! — Mickey Gousset
English · the allowlist's ! blocking and SHA pinning requirements
▶
Scalable governance policies across your GitHub organization — GitHub
English · official channel: organization-level governance (rulesets, policies)
▶
Updates to GitHub Actions Runner Groups — Mickey Gousset
English · runner group access control

Official documentation

Video storyboard (about 80 seconds)

Shot 1 · 0–25s
Visual: three concentric circles: enterprise, organization, repository; the further in, the narrower.
Narration: organization policy is the baseline; lower layers can only be stricter.
Shot 2 · 25–55s
Visual: a uses reference passes the allowlist and SHA checks in turn; an action marked with an exclamation point is stopped.
Narration: the allowlist decides what can be used; the exclamation mark can block a problematic action with one click.
Shot 3 · 55–80s
Visual: the organization scan check appears automatically on the PR; when it fails, the merge button is greyed out.
Narration: the workflow required by the ruleset ensures every repository runs the same set of checks.
or score 70% or more on the quiz

Module 8 · Recap, self-check, and cleanup of the first five hours

54:00 – 60:00 · Connecting the five lessons into one line: collaboration and protection → workflows → OIDC in the cloud → reuse, releases, attestations, and hardening
6 minInteractive troubleshooting treeRemember to revoke token scopes★★★★
Learning goals
  • Use one diagram to retell the full platform path of “a commit from push to production”, and identify which lesson's mechanism protects each step.
  • Use the troubleshooting tree to quickly locate this lesson's common failures: reusable workflow call failures, secrets not passed, GHCR 403, attestation verification failures, and actions blocked by policy.
  • Complete cleanup: test package versions, test Releases, extra token scopes, lab branches, and organization settings.
Importance:★★★★

Five-hour knowledge thread

LessonCore questionKey mechanismsHow it is used in this lesson
Lesson 1How code safely enters mainPRs, reviews, rulesets, CODEOWNERS, merge methodsprotecting platform-workflows; tag rulesets; the ruleset requiring workflows
Lesson 2What happens automatically once code is inevents → workflow → job → runner; matrix, caching, artifacts, environmentsbasic syntax for all workflows
Lesson 3 / Lesson 4How to deploy to the cloud without stored keysOIDC token exchange, federated credentials / IAM roles, immutable subjectsthe same OIDC token mechanism is used for Sigstore signing (module 5)
Lesson 5 (this lesson)How to be reusable, traceable, and trustworthy at organization scalereusable workflows, custom actions, Releases, GHCR, attestations, hardening, governance—

A complete production pipeline

  1. Developers push a branch and open a PR → the ruleset requires review and organization audit workflow (M7) to pass.
  2. Merge into main → myapp's ci.yml calls platform-workflows' python-build (M1); its steps use the setup-myapp composite action and the check-healthz JS action (M2).
  3. The build job uses packages: write to push multi-architecture images to GHCR (M4), and uses actions/attest to generate provenance + SBOM attestations (M5).
  4. Push a v* tag → the release workflow builds assets, creates a draft Release, uploads them, and publishes it as an immutable Release (M3).
  5. The deployment job first gh attestation verify --signer-workflow …, then logs in to the cloud platform with OIDC (Lessons 3/4) to deploy the image digest.
  6. Throughout: all actions pinned by SHA or lock file, jobs with least-privilege permissions, continuous zizmor/Scorecard auditing (M6), with the organization allowlist and Actions policies as the safety net (M7).

Next lesson preview

Hour 6: enterprise security and governance in practice—GHAS (code scanning, secret scanning and push protection, dependency review), security configuration, audit logs, enterprise accounts and EMU. The zizmor/Scorecard results from this lesson feed into the code-scanning alert workflow there.

Panorama: myapp's delivery pipeline five hours later

PRRuleset · audit ci.yml callspython-build@v1 GHCRamd64 + arm64 attestationprovenance · SBOM deployverify → OIDC → cloud tag v* → release.ymldraft → assets → immutable Release + release attestation Hardening (M6)SHA / lock file · permissions: {} · env injection prevention · zizmor · Scorecard · Dependabot Governance (M7)allowlist · SHA requirement · read-only token · ruleset requiring workflows · Actions policies
Figure 8-1: every arrow has a corresponding protection mechanism

Interactive replay: all checkpoints a release passes through

Click “Next” to replay the full path of v0.2.0 from PR to production; tick “Inject fault” to see which checkpoint stops it.

Ready to replay.

Cleanup commands

CommandPurpose
gh api /orgs/ORG/packages/container/myapp/versions --jq '.[].id'List package versions
gh api -X DELETE /orgs/ORG/packages/container/myappDelete an entire package (cannot be recovered after the recovery window)
gh release delete v0.1.0 -R ORG/myapp --cleanup-tag -yDelete a Release and its tag (the name of an immutable Release's tag cannot be reused)
gh secret delete DEMO_TOKEN --org ORGDelete an organization secret
gh auth refresh -h github.com -r admin:org,delete:packages,write:packagesRevoke extra scopes
gh repo delete ORG/check-healthz-action --yesDelete a lab repository (requires delete_repo scope)
docker buildx rm multi && docker logout ghcr.ioLocal cleanup

Lab 8: self-check and cleanup (about 6 min)

Quick self-check: without notes, run the following in myapp and explain the output:
gh run list -R $ORG/myapp -L5
gh api repos/$ORG/myapp/actions/runs/$(gh run list -R $ORG/myapp -w ci -L1 --json databaseId --jq '.[0].databaseId') --jq '.referenced_workflows[].path'
gh attestation verify oci://ghcr.io/$ORG/myapp:latest --repo $ORG/myapp --signer-workflow $ORG/platform-workflows/.github/workflows/python-build.yml
gh release view --json tagName,isImmutable -R $ORG/myapp 2>/dev/null || gh release view -R $ORG/myapp
uvx zizmor@1.32.0 .github/workflows/ --min-severity medium

isImmutable Field names follow the help of gh release view --json .

Decide what to keep: Hour 6 will keep using myorg-lab,myapp, and platform-workflows, so we recommend keeping; you can delete check-healthz-action (if no longer needed), the test tag local-test, the organization secret DEMO_TOKEN.
gh secret delete DEMO_TOKEN --org $ORG
# Optional: delete the lab action repository
gh auth refresh -h github.com -s delete_repo
gh repo delete $ORG/check-healthz-action --yes
revoke token scopes:
gh auth refresh -h github.com -r admin:org,delete:packages,write:packages,delete_repo
gh auth status
Local cleanup: docker buildx rm multi; docker logout ghcr.io; docker image prune -f. If you created a classic PAT for GHCR, delete it under Settings → Developer settings → Personal access tokens.
Redo the module 0 self-assessment and compare scores.

Case: a platform team's 90-day roadmap

Days 1–30: organization default read-only token; switch the allowlist from “all” to “this organization + official + verified + specified” (first export current usage: referenced_workflows and dependency graph); add zizmor to all repositories (non-blocking). Days 31–60: release platform-workflows v1 (build, push, attest), migrate 10 pilot repositories; enable immutable releases; use Dependabot to manage action versions. Days 61–90: the ruleset requires the audit workflow; Require lockfile switches from Evaluate to Active; mandatory gh attestation verify --signer-workflow before deployment. Lesson learned: At each step, “observe” first and then “enforce”; otherwise you will break hundreds of repositories at once.

Interactive troubleshooting tree: common failures in this lesson

Choose step by step based on the symptom to get the diagnostic command and the fix.

Command-line questions
1. Use one command to view the failed step log of the most recent failed run.
gh run view -R myorg-lab/myapp $(gh run list -R myorg-lab/myapp -s failure -L1 --json databaseId --jq '.[0].databaseId') --log-failed
2. Delete the v0.1.0 Release and its tag.
gh release delete v0.1.0 -R myorg-lab/myapp --cleanup-tag -y
Scenario analysis
A new colleague asks: “OIDC is used in Lessons 3 and 4 to log in to the cloud, and in this lesson to sign attestations—is it the same thing?” Please explain.

It is the same ID token issued by the GitHub OIDC provider, except that audience the audience and the receiver differ: when logging in to the cloud, it goes to Azure Entra ID / AWS STS, which validate issuer/audience/subject and then issue short-lived cloud credentials; when generating attestations, it goes to Sigstore Fulcio, which validates it and issues a short-lived signing certificate containing the workflow identity. Both require the job's id-token: write, and both avoid long-lived keys.

Verified instructional videos (comprehensive review)

▶
GitHub Actions Certification – Full Course to PASS the Exam — freeCodeCamp.org
English · long-form course covering certification topics such as reusable workflows, custom actions, and organization management
▶
Complete GitHub Actions Course - From BEGINNER to PRO — DevOps Directive
English · systematic review of the first five hours of Actions content

Official documentation

Video storyboard (about 60 seconds)

Shot 1 · 0–30s
Visual: five checkpoints light up in turn: PR, calling the shared pipeline, pushing images, attestations, deployment verification.
Narration: over five hours, we turned a single commit into reusable, traceable, and verifiable delivery.
Shot 2 · 30–60s
Visual: the cleanup checklist is ticked off item by item, and token scopes shrink.
Narration: remember to clean up after labs, especially by revoking extra token permissions.
or score 70% or more on the quiz

Command cheat sheet

All key syntax and commands in this lesson, grouped by topic
Reusable workflows
on:
  workflow_call:
    inputs:  { env: { type: string, required: true } }
    secrets: { TOKEN: { required: true } }
    outputs: { digest: { value: ${{ jobs.b.outputs.d }} } }
---
jobs:
  call:
    uses: org/repo/.github/workflows/f.yml@<sha|tag>
    with: { env: prod }
    secrets: inherit          # same organization; reaches only direct callees
    permissions: { contents: read }

Limits: 10 levels of nesting · 50 distinct workflows · env does not propagate · permissions can only be lowered, not raised

Custom actions
runs: { using: node24, main: dist/index.js }
runs: { using: docker, image: docker://ghcr.io/o/i@sha256:… }
runs:
  using: composite
  steps:
    - run: echo hi
      shell: bash
    - uses: $/actions/other      # same-repository self-reference
npx @vercel/ncc build src/index.js -o dist --license licenses.txt
git tag -f v1 v1.2.0^{} && git push -f origin v1
Release
gh release create v1.2.0 --draft --verify-tag --generate-notes
gh release upload v1.2.0 dist/*
gh release edit v1.2.0 --draft=false
gh release verify v1.2.0
gh release verify-asset v1.2.0 dist/app.whl
gh api repos/O/R/releases/generate-notes -f tag_name=v1.2.0
GHCR
gh auth token | docker login ghcr.io -u USER --password-stdin
docker buildx build --platform linux/amd64,linux/arm64 -t ghcr.io/o/app:1 --push .
docker buildx imagetools inspect ghcr.io/o/app:1
gh api /orgs/O/packages/container/app/versions
gh api -X DELETE /orgs/O/packages/container/app/versions/ID

workflow: packages: write + GITHUB_TOKEN; LABEL org.opencontainers.image.source

Attestations
permissions: { id-token: write, attestations: write, packages: write, artifact-metadata: write }
- uses: actions/attest@1e69f48acb82d1966a394da916b4c1698aa569d6 # v4.2.2
  with: { subject-name: ghcr.io/o/app, subject-digest: ${{ steps.push.outputs.digest }}, push-to-registry: true }
- uses: actions/attest@… # sbom-path: sbom.spdx.json
gh attestation verify oci://ghcr.io/o/app:1 --repo o/app \
  --signer-workflow o/platform-workflows/.github/workflows/build.yml \
  --source-ref refs/heads/main --deny-self-hosted-runners
gh attestation verify f --repo o/app --predicate-type https://spdx.dev/Document/v2.3
Hardening
permissions: {}
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
  with: { persist-credentials: false }
- env: { TITLE: ${{ github.event.pull_request.title }} }
  run: echo "$TITLE"
git ls-remote https://github.com/O/R refs/tags/vX.Y.Z
gh extension install github/gh-actions-lock && gh actions-lock
uvx zizmor .github/workflows/
GH_TOKEN=$(gh auth token) uvx zizmor .
Organization governance
gh api -X PUT orgs/O/actions/permissions -f enabled_repositories=all -f allowed_actions=selected
gh api -X PUT orgs/O/actions/permissions/selected-actions --input sel.json
gh api -X PUT orgs/O/actions/permissions/workflow -f default_workflow_permissions=read -F can_approve_pull_request_reviews=false
gh secret set NAME --org O --visibility selected --repos a,b
gh api orgs/O/rulesets
gh api orgs/O/actions/runner-groups
Troubleshooting
gh run view RUN --log-failed
gh run view RUN --json jobs --jq '.jobs[] | "\(.name) \(.conclusion)"'
gh api repos/O/R/actions/runs/RUN --jq .referenced_workflows
gh api repos/O/R/attestations/sha256:…
gh run rerun RUN --failed --debug

Integrated lab + final quiz

Refactor myapp's CI/CD into “organization-shared reusable workflows + custom composite actions”, publish multi-architecture images to GHCR, generate and verify build attestations, then use audit tools to check the hardening items
After class ≈ 40 minCovers all modulesCost: 0 (public repositories)
Scenario The security team at myorg-lab sets four requirements: ① all application repositories use the unified build pipeline maintained by the platform team, and application repositories only write calls; ② images support both amd64 and arm64 and are stored in GHCR; ③ every image must carry provenance and SBOM attestations issued by the platform workflow and verified before deployment; ④ workflows must pass zizmor and Scorecard audits, and all third-party actions must be pinned. Complete this in myorg-lab/platform-workflows and myorg-lab/myapp , and self-verify with the acceptance checklist.
Platform repository structure (modules 1 and 2)
cd ~/src/platform-workflows
tree -a -I .git
.
├── .github
│   ├── dependabot.yml
│   └── workflows
│       ├── container-build.yml     # reusable workflow created in this lab
│       ├── python-build.yml        # modules 1/5
│       └── audit.yml               # module 7 (required by ruleset)
└── actions
    └── setup-myapp
        └── action.yml              # composite action
Write container-build.yml (modules 1, 4, 5): test (composite action) → image (multi-architecture push + attestations).
name: container-build
on:
  workflow_call:
    inputs:
      python-version: { type: string, default: "3.12" }
      platforms:      { type: string, default: "linux/amd64,linux/arm64" }
      push:           { type: boolean, default: false }
    outputs:
      digest:
        value: ${{ jobs.image.outputs.digest }}
      image:
        value: ${{ jobs.image.outputs.image }}
permissions: {}
jobs:
  test:
    runs-on: ubuntu-24.04
    permissions: { contents: read }
    steps:
      - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
        with: { persist-credentials: false }
      - uses: $/actions/setup-myapp
        with: { python-version: "${{ inputs.python-version }}" }
      - run: pytest -q
  image:
    needs: test
    runs-on: ubuntu-24.04
    permissions:
      contents: read
      packages: write
      id-token: write
      attestations: write
      artifact-metadata: write
    outputs:
      digest: ${{ steps.push.outputs.digest }}
      image: ${{ steps.name.outputs.image }}
    steps:
      - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
        with: { persist-credentials: false }
      - id: name
        run: echo "image=ghcr.io/${GITHUB_REPOSITORY,,}" >> "$GITHUB_OUTPUT"
      - uses: docker/setup-qemu-action@99012661954931238ded8c8b007157a8430204e1 # v4.4.0
      - uses: docker/setup-buildx-action@f87e5991a6d7451dcb8d9637bfbc97413f497069 # v4.4.1
      - if: inputs.push
        uses: docker/login-action@8aa5831fb8d48d8f76594c7ddde61ae58019f550 # v4.8.0
        with: { registry: ghcr.io, username: "${{ github.actor }}", password: "${{ secrets.GITHUB_TOKEN }}" }
      - id: meta
        uses: docker/metadata-action@dc802804100637a589fabce1cb79ff13a1411302 # v6.2.0
        with:
          images: ${{ steps.name.outputs.image }}
          tags: |
            type=semver,pattern={{version}}
            type=sha
            type=raw,value=latest,enable={{is_default_branch}}
      - id: push
        uses: docker/build-push-action@c3c9e263c25d99ce0380d002d59b67737d91b0dc # v7.4.0
        with:
          platforms: ${{ inputs.platforms }}
          push: ${{ inputs.push }}
          tags: ${{ steps.meta.outputs.tags }}
          labels: ${{ steps.meta.outputs.labels }}
          annotations: ${{ steps.meta.outputs.annotations }}
      - if: inputs.push
        uses: actions/attest@1e69f48acb82d1966a394da916b4c1698aa569d6 # v4.2.2
        with:
          subject-name: ${{ steps.name.outputs.image }}
          subject-digest: ${{ steps.push.outputs.digest }}
          push-to-registry: true
      - if: inputs.push
        uses: anchore/sbom-action@fffec3d851af758d56fee099cf3fbf8aa8779843 # v0.24.3
        with:
          image: ${{ steps.name.outputs.image }}@${{ steps.push.outputs.digest }}
          format: spdx-json
          output-file: sbom.spdx.json
      - if: inputs.push
        uses: actions/attest@1e69f48acb82d1966a394da916b4c1698aa569d6 # v4.2.2
        with:
          subject-name: ${{ steps.name.outputs.image }}
          subject-digest: ${{ steps.push.outputs.digest }}
          sbom-path: sbom.spdx.json
          push-to-registry: true
git add . && git commit -m "feat: container-build reusable workflow" && git push
git tag -a v2.0.0 -m v2.0.0 && git tag -f v2 && git push origin v2.0.0 && git push -f origin v2
V2_SHA=$(git rev-parse v2.0.0^{}); echo $V2_SHA
Change myapp to call it, and verify before deployment (modules 1, 5): calls are pinned by SHA (the lock file does not cover reusable workflow calls).
name: cicd
on:
  push: { branches: [main] }
  pull_request:
permissions: {}
jobs:
  build:
    uses: myorg-lab/platform-workflows/.github/workflows/container-build.yml@<V2_SHA> # v2.0.0
    with:
      push: ${{ github.event_name == 'push' }}
    permissions:
      contents: read
      packages: write
      id-token: write
      attestations: write
      artifact-metadata: write
  verify:
    if: github.event_name == 'push'
    needs: build
    runs-on: ubuntu-24.04
    permissions: { contents: read, attestations: read, packages: read }
    steps:
      - env:
          GH_TOKEN: ${{ github.token }}
          IMAGE: ${{ needs.build.outputs.image }}
          DIGEST: ${{ needs.build.outputs.digest }}
        run: |
          gh attestation verify "oci://$IMAGE@$DIGEST" --repo "$GITHUB_REPOSITORY" \
            --signer-workflow myorg-lab/platform-workflows/.github/workflows/container-build.yml \
            --source-ref refs/heads/main --deny-self-hosted-runners
          echo "✅ verified $IMAGE@$DIGEST" >> "$GITHUB_STEP_SUMMARY"

Delete the old ci.yml / publish-image.yml to avoid duplicate builds. verify After the job comes the OIDC deployment job from Lessons 3/4 (deploy by digest).

Run and check (modules 4, 5)
cd ~/src/myapp && git add -A .github && git commit -m "ci: use org container-build workflow" && git push org main
RUN=$(gh run list -R $ORG/myapp -w cicd -L1 --json databaseId --jq '.[0].databaseId'); gh run watch -R $ORG/myapp $RUN
docker buildx imagetools inspect ghcr.io/$ORG/myapp:latest | grep Platform
gh attestation verify oci://ghcr.io/$ORG/myapp:latest --repo $ORG/myapp --predicate-type https://spdx.dev/Document/v2.3 >/dev/null && echo SBOM-OK
Hardening and auditing (module 6)
for d in ~/src/platform-workflows ~/src/myapp; do (cd $d && GH_TOKEN=$(gh auth token) uvx zizmor@1.32.0 .github/); done
cd ~/src/myapp && gh actions-lock && git add .github/workflows/actions.lock && git commit -m "ci: lock action deps" && git push org main

Commit dependabot.yml (github-actions ecosystem, with cooldown) and audit.yml (zizmor + Scorecard), and confirm there are no high-severity alerts under Security → Code scanning.

Organization governance (module 7): allowlist “this organization + official + verified + specified (ossf/*, zizmorcore/*, anchore/sbom-action@*)”; enable the SHA pinning requirement; default token read-only; (depending on plan) ruleset requires audit.yml; create branch and tag rulesets for platform-workflows (only the platform team can push main and v* tags).
Negative tests: ① overwrite-push a local latest , then run the verification command and confirm it fails; ② on a new myapp branch add tj-actions/changed-files@v46.0.1, and confirm it is blocked by organization policy; ③ in cicd.yml, remove the calling job's id-token: write is removed, confirm the run fails at startup. After restoring everything, re-run CI.
Acceptance checklist

Open-ended self-test (answer on your own first, then expand the reference answers)

1. What passing rules do secrets, env, and permissions each follow in reusable workflows?

secrets must be passed explicitly or inherit (same organization/enterprise), reaching only direct callees; workflow-level env propagates in neither direction, so use inputs/outputs or vars; GITHUB_TOKEN permissions can only be kept or lowered; if a called job requests more than the calling job grants, the run fails at startup.

2. After enabling immutable releases, how is the action's major-version tag v1 still maintained?

Create a Release for each fixed version (v1.2.3) (immutable); v1 and v1.2 exist only as Git tags, not linked to a Release, and can be force-moved. Users who want determinism should reference a SHA or an immutable version.

3. Why are both “deploying images by tag” and “verifying only with --owner” insufficient?

tags can be overwritten, and attestations are bound to the digest, so deploy and verify by digest; --owner proving only that something came from some workflow in some repository within the organization can be satisfied by any compromised or low-privilege repository, so add --signer-workflow (pinning the platform reusable workflow),--source-ref,--deny-self-hosted-runners.

4. Which SLSA level do artifact attestations reach? How do you get to L3?

On their own, they provide SLSA v1.0 Build L2; putting the build and attestation into an organization-shared reusable workflow isolates the build definition from the caller, and pinning that workflow during verification satisfies Build L3.

5. Explain the pwn request, and the two protections GitHub added in 2026.

Checking out or downloading fork code and executing it in privileged triggers with secrets or write tokens (pull_request_target,workflow_run,issue_comment etc.). Protections: actions/checkout v7 denies by default checking out fork code in pull_request_target/workflow_run (requires allow-unsafe-pr-checkout); the Actions policy adds a default event policy that blocks pull_request_target for public repositories, enforced from 2026-12-02.

6. What are the pros and cons of SHA pinning compared with workflow dependency lock files?

SHA pinning is simple and works everywhere, but workflows are harder to read, it does not cover transitive dependencies, it does not record repository identity, and Dependabot vulnerability alerts do not cover SHA references. Lock files cover transitive dependencies, record owner/repo IDs and verify them at runtime, let workflows keep tag syntax, and satisfy the organization's SHA pinning policy, but require gh actions-lock a toolchain, and do not cover reusable workflow calls and ./ local actions; they are not supported on GHES $/.

Final quiz (12 questions, covering all modules)

Sources and version notes

Verification basis for all technical facts in this lesson (verified 2026-11-15)
TopicVerified conclusionSource (accessed 2026-11-15)
Reusable workflow limitsUp to 10 levels; a single workflow file can call up to 50 distinct reusable workflows (including the nested tree); env does not propagate; keywords usable in the calling job (including cache-mode); permissions can only be kept or lowered; hosted runners are allocated and billed to the caller; re-run behavior for non-SHA referencesReusing workflow configurations
secrets passinginherit limited to the same organization/enterprise; secrets go only to direct callees; an unpassed secret resolves to an empty string, and can be used required: trueReuse workflows
$/ self-referenceresolves to the commit currently running, needs no checkout, cannot take @ref, and is not supported on GHESWorkflow syntax
JS action runtimeruns.using node20 / node24 are optional; the official template uses node24,@actions/core ^3 (latest npm 3.0.1), rollup bundling; ncc 0.45.0 (2026-08-13) automatically outputs ESM for ESM packagesMetadata syntax · javascript-action · vercel/ncc
MarketplacePublic repository, a single action.yml in the root, unique name, accepts the developer agreement, 2FA required for publishing, no manual reviewPublishing actions in GitHub Marketplace
Immutable releases2025-08-26 public preview, 2025-10-28 GA; tags locked, assets immutable, tag names cannot be reused after deletion, release attestations generated automatically; titles and notes editable; recommended order draft → assets → publish; major-version tags not linked to a ReleaseChangelog · Immutable releases · Action releases
Release notes.github/release.yml exclude / categories configuration ofAutomatically generated release notes
GHCRonly classic PATs and GITHUB_TOKEN are supported; publishing from a workflow links automatically and grants admin; inherits access permissions but not visibility; private on first publish; cannot be changed back once public; public packages can be pulled anonymously; Container registry storage and bandwidth are currently freeContainer registry · Access control · Packages billing
Artifact attestationsactions/attest v4.2.2 (2026-08-04); attest-build-provenance v4.2.2 is the wrapper; attest-sbom v4.1.0 being deprecated; permissions id-token / attestations / artifact-metadata; public repositories use the Sigstore public instance + Rekor, private repositories use the GitHub instance (no transparency log, requires GHEC); SLSA v1.0 Build L2 is provided alone, and reusable workflows reach L3actions/attest · Artifact attestations · Using attestations
gh CLIv2.104.0 (2026-11-12); gh attestation verify parameters: --owner/--repo, --signer-workflow, --signer-repo, --source-ref, --deny-self-hosted-runners, --predicate-type, --bundle, --bundle-from-oci, --custom-trusted-root, etc.; gh release verify / verify-assetcli/cli releases · manual
Security hardeningpull_request_target risks and the default event policy (evaluate; enforced 2026-12-02), read-only caches; checkout v7 blocks fork PR checkout by default,allow-unsafe-pr-checkout; lock files .github/workflows/actions.lock and gh actions-lock; Dependabot alerts do not cover SHA-pinned actionsSecurely using pull_request_target · actions/checkout · Lockfiles · Secure use
Audit toolszizmor v1.32.0 (2026-11-02), zizmor-action v0.8.1; ossf/scorecard-action v2.5.0 (2026-10-12)zizmor · scorecard-action
Docker actionsbuild-push v7.4.0, setup-buildx v4.4.1, setup-qemu v4.4.0, login v4.8.0, metadata v6.2.0; delete-package-versions v5.0.0; anchore/sbom-action v0.24.3; SHAs obtained by git ls-remote fetchingeach repository's GitHub Releases
Organization governanceAllowlist syntax and ! blocking, the 1000-entry limit, the SHA pinning requirement (reusable workflows excepted), lock files matched by SHA; restricted token = contents/packages read-only; Actions policies (actor/event rules, Require lockfile, Evaluate GHEC only); private repositories in Free organizations cannot use organization secrets; additional runner groups require TeamLimiting Actions · Actions policies · Secrets · Runner groups
Required workflowsLegacy Actions required workflows are no longer supported; use the organization/enterprise ruleset “Require workflows to pass before merging” instead; events limited to pull_request / pull_request_target / merge_groupGHES 3.10 notes · GitHub Blog
tj-actions incidentCVE-2025-30066 / GHSA-mrrh-fwg8-r2c3; 2025-03-14/15 tags repointed; fixed in 46.0.1GitHub Advisory

Video verification notes

All videos listed in this lesson were verified on 2026-11-15 via the YouTube oEmbed endpoint (https://www.youtube.com/oembed?url=…&format=json), checking titles and channels: CoderDave (lRypYtmbKMs, zc19mR3O4a4, p9ismkYDxWQ, WjzA9dfk5w4), Mickey Gousset (gDBZGCGSs6E, zQdEsIBbVjE, 4dnniFk5i2Q, sXDBEofeMcY), Colby Fayock (Ef0gPGUh9oo), Yankee Maharjan (w8ZALhqoHgs), GitHub (88FWrfHCIqo, zTIHb-9c868, dNl3qpJZ12w), Ana's Dev Scribbles (70YgbPh6pXA), Brian Morrison (RgZyX-e6W9E), Cloud Native Skunkworks (hAcMGttHCFw), NDC Conferences (hF95PiItWtM), William Woodruff (WF0HgaH-qtY), Black Hat (-BCngzJC1Rc), The Linux Foundation (YTHqoST99oE), freeCodeCamp.org (Tz7FsunBbfQ), DevOps Directive (Xwpi0ITkL3U). Some videos were recorded earlier; version numbers and limit figures follow the body of this lesson.

Voice narration notes

The “Voice” page uses the browser Web Speech API (speechSynthesis, en-US) to read the narration script aloud in real time; English terms are pronounced with en-US; the result depends on the voices installed on the system. This courseware does not embed MP3s; for offline audio, give the narration script to any TTS tool.

Known limitations

  • Run IDs, digests, SHAs (except explicitly labeled action version SHAs), times, and counts in “Expected output” are example values.
  • The action version SHAs were looked up on 2026-11-15 using git ls-remote ; re-query before use. Examples without pinned SHAs (such as actions/setup-python@v7,github/codeql-action/upload-sarif@v4) are marked “also pin the SHA in production”.
  • GitHub UI paths and some REST fields (such as sha_pinning_required,gh release view --json isImmutable) change quickly; the courseware marks them as “follow the docs”.
  • The plan requirements for the “Require workflows to pass before merging” rule and Actions policies could not be found stated explicitly on the current docs.github.com pages; the courseware offers an alternative (reusable workflow + required status check).
  • Exact error messages follow actual runs; text marked “follow the actual result” in the troubleshooting pages is typical wording inferred from the mechanism.
  • Times and flows in the animations are illustrative, to explain the mechanisms, and do not represent actual durations.