Repository navigation
Attach source/commit provenance to published container images - #417
Merged
Merged
Conversation
I added source/revision labels and build-provenance attestation to both Docker Hub publishing workflows. Nothing has been run, so none of it is tested.
**Registries found:** Docker Hub only, as `${{ secrets.DOCKER_HUB_USER }}/graphmindset`. There is no ghcr.io push. `build-check.yml` doesn't publish, so I left it alone.
**Workflows changed:**
- `.github/workflows/docker-build.yml` (on release; tags `RELEASE_TAG` and `latest`).
- `.github/workflows/docker-build-main.yml` (on push to main; tag `main`).
**Changes in each:**
- **Labels:** both workflows use plain `docker build` and `docker push`, not `build-push-action`. I added `--label org.opencontainers.image.source=<server_url>/<repo>` and `--label org.opencontainers.image.revision=<sha>` to the `docker build` command. I did not add `docker/metadata-action`, because there is no build-push-action step to pass its outputs to. So there are no manifest annotations, only labels.
- **Permissions:** neither job had a permissions block, so I added `contents: read`, `id-token: write` and `attestations: write`. `packages: write` isn't needed because nothing goes to ghcr.
- **Digest:** a new step resolves the pushed digest with `docker buildx imagetools inspect <image>:<tag> --format '{{.Manifest.Digest}}'`. In the release workflow it inspects the `RELEASE_TAG` tag, which points at the same image as `latest`.
- **Attestation:** `actions/attest-build-provenance@v2` runs with `subject-name: index.docker.io/${{ secrets.DOCKER_HUB_USER }}/graphmindset`, the digest from the step above, and `push-to-registry: true`. It has the `gh attestation verify oci://… --owner stakwork` comment above it.
Existing tags, triggers, login and push steps are unchanged. Neither workflow sets any provenance or sbom option, so there is nothing to carry over there.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
I added source/revision labels and build-provenance attestation to both Docker Hub publishing workflows. Nothing has been run, so none of it is tested.
Registries found: Docker Hub only, as
${{ secrets.DOCKER_HUB_USER }}/graphmindset. There is no ghcr.io push.build-check.ymldoesn't publish, so I left it alone.Workflows changed:
.github/workflows/docker-build.yml(on release; tagsRELEASE_TAGandlatest)..github/workflows/docker-build-main.yml(on push to main; tagmain).Changes in each:
docker buildanddocker push, notbuild-push-action. I added--label org.opencontainers.image.source=<server_url>/<repo>and--label org.opencontainers.image.revision=<sha>to thedocker buildcommand. I did not adddocker/metadata-action, because there is no build-push-action step to pass its outputs to. So there are no manifest annotations, only labels.contents: read,id-token: writeandattestations: write.packages: writeisn't needed because nothing goes to ghcr.docker buildx imagetools inspect <image>:<tag> --format '{{.Manifest.Digest}}'. In the release workflow it inspects theRELEASE_TAGtag, which points at the same image aslatest.actions/attest-build-provenance@v2runs withsubject-name: index.docker.io/${{ secrets.DOCKER_HUB_USER }}/graphmindset, the digest from the step above, andpush-to-registry: true. It has thegh attestation verify oci://… --owner stakworkcomment above it.Existing tags, triggers, login and push steps are unchanged. Neither workflow sets any provenance or sbom option, so there is nothing to carry over there.