1. Building and publishing #
An image traced back to its commit.
The workflow #
jobs:
image:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
attestations: write
id-token: write
steps:
- uses: actions/checkout@v7
- uses: docker/login-action@v4
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- id: meta
uses: docker/metadata-action@v6
with:
images: ghcr.io/${{ github.repository }}
tags: type=sha
- id: push
uses: docker/build-push-action@v7
with:
push: true
tags: ${{ steps.meta.outputs.tags }}
- uses: actions/attest-build-provenance@v4
with:
subject-name: ghcr.io/${{ github.repository }}
subject-digest: ${{ steps.push.outputs.digest }}
push-to-registry: true
production:
needs: image
runs-on: ubuntu-latest
environment:
name: production
url: https://boutique.exemple.fr
permissions:
id-token: write
contents: read
steps:
- uses: aws-actions/configure-aws-credentials@v5
with:
role-to-assume: arn:aws:iam::123456789012:role/shop-deployment
aws-region: eu-west-3
- run: ./deploy.sh ${{ needs.image.outputs.tag }}GITHUB_TOKENis a temporary token created for each run; its rights are set withpermissions(here, writing packages).- A signed provenance attestation proves which workflow, on which commit, produced the image; it is verified with
gh attestation verify.
2. Environments and OIDC #
Controlling who deploys and with which rights.
Environments #
| Protection rule | Effect |
|---|---|
| Required reviewers | the job waits for approval from a designated person or team |
| Wait timer | pause before deployment (1 to 43,200 minutes) |
| Deployment branches | only some branches or tags can target the environment |
| Environment secrets | only available to jobs of that environment, after approval |
With id-token: write, the job gets a GitHub-signed OIDC token that the cloud exchanges for temporary rights. The trust relationship specifies the repository and environment (repo:org/repo:environment:production): no key to store.
Best practice : Put production secrets in the production environment, never at repository level: they are then only exposed after approval.Commands to know #
Commands to know
gh attestation verify oci://ghcr.io/org/boutique:sha-abc1234 --owner org: verify an image's provenancegh run list --workflow deploy.yml: deployment historygh release create v1.2.0 --generate-notes: create a release
Sources #
Checked in November 2026: CI/CD platforms change every month, check versions and plans in the vendor's documentation.
My progress
Sign in to track your progress and take notes. Sign in
💬 Questions about this lesson
No questions yet: be the first to ask for help or share your configuration.
Recommended Articles
Building and delivering with GitLab: registry, environments and deployments
Delivering with GitLab CI/CD: building and publishing images to the project registry, package reg...
GitHub Actions runners: hosted, self-hosted and ARC
Choosing where workflows run: hosted runners and images, larger runners, self-hosted runners (ins...
GitHub Actions: concepts and how it works
Discover GitHub Actions: events, workflows, jobs, steps and actions, the Marketplace, hosted runn...
End-to-end CI/CD (3/5): artifacts, registries and environments
Deliver continuously: immutable, versioned artifacts, image and package registries, promoting the...
Reusing and securing GitHub Actions workflows
Industrializing GitHub Actions: reusable workflows, composite, JavaScript and Docker actions, lea...
Writing GitHub Actions workflows
Mastering workflow syntax: triggers and filters, jobs and needs, matrices, if conditions, context...
GitHub Actions best practices and troubleshooting
Running GitHub Actions: speeding up and cutting costs, debugging (debug logs, act locally, gh run...
Deploying with Azure Pipelines: environments, approvals and service connections
Delivering with Azure Pipelines: multi-stage pipelines, environments, approvals and checks, deplo...
Container registry: choosing and securing your image registry (Docker Hub, Harbor, GHCR, ECR)
Understand container registries: Docker Hub, GitHub Container Registry, cloud registries (ECR, AC...