-
Notifications
You must be signed in to change notification settings - Fork 3
build reusable workflow #4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 12 commits
Commits
Show all changes
72 commits
Select commit
Hold shift + click to select a range
9353c30
build reusable workflow
crazy-max 764760b
build: set meta labels and annotations
crazy-max 5f1cddf
build: build args
crazy-max 717a2c9
build: build platforms
crazy-max 0798ce3
build: install cosign and sign image
crazy-max 61af3a9
build: use oci-artifact for attestations
crazy-max eadc552
build: step to get attestation manifest digest for signing
crazy-max 37b4f8f
build: only sign attestation manifests
crazy-max c7eb418
build: verify signatures
crazy-max d640474
build: verify each signature individually
crazy-max 80c78b2
build: build-sbom input
crazy-max 82581c8
build: push by digest and create manifest in last step
crazy-max 2da5a1f
build: use getMultilineInput from core toolkit
crazy-max 2abd569
build: sign and verify only with referrers API
crazy-max 934c903
build: enforce github-actions provider for signing
crazy-max a6745e6
testing dockerhub oidc through login-action
crazy-max 2235615
build: fix since pushing by digest
crazy-max e9fcf9a
build: show image manifest
crazy-max 3092e48
build: wait 3sec before verifying
crazy-max 5b31101
build: fail if we can't verify the signature
crazy-max f0f7db8
build: don't verify each tag, just digest
crazy-max 00ecfae
build: switch push input to build-output one
crazy-max cbb1824
build: remove timeout on verification
crazy-max 85225d9
build: format exec
crazy-max f078345
build: retry signature verification
crazy-max c69dd2b
build: support local output and sign attestations blob
crazy-max b52998e
build: install latest buildx and enable buildkit debug
crazy-max cd349f2
build: pin cosign installer action
crazy-max 8a7c5db
build: multi registry auths
crazy-max f24613e
build: update login-action
crazy-max 55bf27e
build: list output after build for local build
crazy-max ea18033
build: fix signing for multi platform with local output
crazy-max e4e069b
build: install cosign from sources
crazy-max e663908
build: clone cosign repo
crazy-max 8a99b29
build: use cosign fork with debug on write
crazy-max d8d8b7e
build: cosign 2.6.0 ref
crazy-max 0860319
build: use cosign installer
crazy-max 7f3ba6c
build: use cosign 2.6.0-debug-oci-write branch
crazy-max dfdfca0
build: use cosign 2.6.0-fix-oci-manifest branch
crazy-max 81636c5
build: buildkit latest image
crazy-max 3309be0
build: install cosign earlier
crazy-max ee15022
build: set github_event as provenance custom field
crazy-max 27f850d
build: let buildx mount github event for provenance
crazy-max f4fc0a5
build: less aggressive retry backoff
crazy-max 3bb7e15
build: use cosign bundle for local signature
crazy-max 939d82d
build: add origin annotation to signing payload
crazy-max b68a5f8
build: use attest-blob to embed attestation in DSSE
crazy-max da23358
build: use buildkit latest stable
crazy-max cd6f835
build: new bundle format for local
crazy-max 6124b66
build: format local cosign bundle
crazy-max 432cfba
build: verify signatures for local artifacts as well
crazy-max a7174e2
build: only sign provenance attestation
crazy-max 5c24e0d
build: slsa provenance v1
crazy-max d2a2e67
build: use actions/attest@v2 to sign local artifacts
crazy-max 9365692
build: use fork of actions/attest to skip wrting attestation on GH repo
crazy-max 6893c72
build: disable local signature verification temporarily
crazy-max 9536b5a
build: test not uploading to transparency log
crazy-max 67ef79b
build: use cosign 3.0.2-fix-oci-manifest branch and new-bundle-format…
crazy-max abb5893
build: buildx pr-3453 merged
crazy-max ad2c478
build: testing actions-toolkit implementation to sign blobs
crazy-max 300850c
build: build-file input
crazy-max 18f51b9
build: use actions-toolkit to install cosign and verify blobs signature
crazy-max 89c21b6
build: use vanilla cosign v3.0.2
crazy-max b291252
build: use actions-toolkit to sign and verify attestation manifests
crazy-max 41db215
build: cleanup workflow
crazy-max 2f92945
build: install actions-toolkit 0.65.0
crazy-max c903453
build: cache and cache-mode inputs for GitHub Actions cache backend
crazy-max aa5750d
build: setup qemu opt
crazy-max 23a491f
build: support multiple image names
crazy-max 46d1973
build: add remaining build inputs
crazy-max 144584b
build: update actions-toolkit to 0.67.0
crazy-max 5fdc350
update README
crazy-max File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,238 @@ | ||
| name: build | ||
|
|
||
| on: | ||
| workflow_call: | ||
| inputs: | ||
| push: | ||
| type: boolean | ||
| description: "Push image to registry" | ||
| required: false | ||
| default: false | ||
| set-meta-annotations: | ||
| type: boolean | ||
| description: "Set metadata-action annotations" | ||
| required: false | ||
| default: false | ||
| set-meta-labels: | ||
| type: boolean | ||
| description: "Set metadata-action labels" | ||
| required: false | ||
| default: false | ||
| meta-image: | ||
| type: string | ||
| description: "Image to use as base name for tags" | ||
| required: true | ||
| meta-tags: | ||
| type: string | ||
| description: "List of tags as key-value pair attributes" | ||
| required: false | ||
| meta-flavor: | ||
| type: string | ||
| description: "Flavors to apply" | ||
| required: false | ||
| meta-labels: | ||
| type: string | ||
| description: "List of custom labels" | ||
| required: false | ||
| meta-annotations: | ||
| type: string | ||
| description: "List of custom annotations" | ||
| required: false | ||
| login-registry: | ||
| type: string | ||
| description: "Server address of Docker registry. If not set then will default to Docker Hub" | ||
| required: false | ||
| login-username: | ||
| type: string | ||
| description: "Username used to log against the Docker registry" | ||
| required: false | ||
| login-ecr: | ||
| type: string | ||
| description: "Specifies whether the given registry is ECR (auto, true or false)" | ||
| default: 'auto' | ||
| required: false | ||
| build-args: | ||
| type: string | ||
| description: "List of build-time variables" | ||
| required: false | ||
| build-platforms: | ||
| type: string | ||
| description: "List of target platforms to build" | ||
| required: false | ||
| build-sbom: | ||
| type: string | ||
| description: "Generate SBOM attestation for the build (shorthand for --attest=type=sbom)" | ||
| required: false | ||
| secrets: | ||
| login-password: | ||
| description: "Password or personal access token used to log against the Docker registry" | ||
| required: false | ||
| github-token: | ||
| description: "GitHub Token used to authenticate against a repository for Git context" | ||
| required: false | ||
|
|
||
| jobs: | ||
| build: | ||
| runs-on: ubuntu-latest | ||
| permissions: | ||
| contents: read | ||
| packages: write # needed for pushing the images to GitHub Packages | ||
| id-token: write # needed for signing the images with GitHub OIDC Token | ||
| steps: | ||
| - | ||
| name: Validate | ||
| uses: actions/github-script@v7 | ||
| env: | ||
| INPUT_META-IMAGE: ${{ inputs.meta-image }} | ||
| with: | ||
| script: | | ||
| function getInputList(name) { | ||
| return core.getInput(name) ? core.getInput(name).split(/[\r?\n,]+/).filter(x => x !== '') : []; | ||
| } | ||
| if (getInputList('meta-image').length > 1) { | ||
| throw new Error('Only one meta-image is allowed'); | ||
| } | ||
| - | ||
| name: Set up Docker Buildx | ||
| uses: docker/setup-buildx-action@v3 | ||
| - | ||
| name: Login to registry | ||
| uses: docker/login-action@v3 | ||
| if: ${{ inputs.push }} | ||
| with: | ||
| registry: ${{ inputs.login-registry }} | ||
| username: ${{ inputs.login-username }} | ||
| password: ${{ secrets.login-password }} | ||
| ecr: ${{ inputs.login-ecr }} | ||
| - | ||
| name: Docker meta | ||
| id: meta | ||
| uses: docker/metadata-action@v5 | ||
| with: | ||
| images: ${{ inputs.meta-image }} | ||
| tags: ${{ inputs.meta-tags }} | ||
| flavor: ${{ inputs.meta-flavor }} | ||
| labels: ${{ inputs.meta-labels }} | ||
| annotations: ${{ inputs.meta-annotations }} | ||
| - | ||
| name: Build | ||
| id: build | ||
| uses: docker/build-push-action@v6 | ||
| with: | ||
| build-args: ${{ inputs.build-args }} | ||
| platforms: ${{ inputs.build-platforms }} | ||
| outputs: type=image,"name=${{ inputs.meta-image }}",oci-artifact=true,push-by-digest=true,name-canonical=true,push=${{ inputs.push }} | ||
| sbom: ${{ inputs.build-sbom }} | ||
| labels: ${{ inputs.set-meta-labels && steps.meta.outputs.labels || '' }} | ||
| annotations: ${{ inputs.set-meta-annotations && steps.meta.outputs.annotations || '' }} | ||
| github-token: ${{ secrets.github-token || github.token }} | ||
| - | ||
| name: Get attestations digest | ||
| id: attest | ||
| uses: actions/github-script@v7 | ||
| env: | ||
| INPUT_TAGS: ${{ steps.meta.outputs.tags }} | ||
| with: | ||
| script: | | ||
| function getInputList(name) { | ||
| return core.getInput(name) ? core.getInput(name).split(/[\r?\n,]+/).filter(x => x !== '') : []; | ||
| } | ||
| await core.group(`Get attestations digest`, async () => { | ||
| await exec.getExecOutput('docker', ['buildx', 'imagetools', 'inspect', getInputList('tags')[0], '--format', '{{json .Manifest}}'], { | ||
| ignoreReturnCode: true, | ||
| silent: true | ||
| }).then(res => { | ||
| if (res.stderr.length > 0 && res.exitCode != 0) { | ||
| throw new Error(res.stderr); | ||
| } | ||
| const dt = JSON.parse(res.stdout.trim()); | ||
| const attestationDigests = dt.manifests.filter(m => m.annotations && m.annotations['vnd.docker.reference.type'] === 'attestation-manifest').map(m => m.digest); | ||
| core.info(JSON.stringify(attestationDigests, null, 2)); | ||
| core.setOutput('digests', attestationDigests.join('\n')); | ||
| }); | ||
| }); | ||
| - | ||
| name: Install cosign | ||
| if: ${{ inputs.push }} | ||
| uses: sigstore/cosign-installer@v3 | ||
| - | ||
| name: Sign with GitHub OIDC Token | ||
| if: ${{ inputs.push }} | ||
| uses: actions/github-script@v7 | ||
| env: | ||
| INPUT_TAGS: ${{ steps.meta.outputs.tags }} | ||
| INPUT_DIGESTS: ${{ steps.attest.outputs.digests }} | ||
| with: | ||
| script: | | ||
| function getInputList(name) { | ||
| return core.getInput(name) ? core.getInput(name).split(/[\r?\n,]+/).filter(x => x !== '') : []; | ||
| } | ||
| const tags = getInputList('tags'); | ||
| const digests = getInputList('digests'); | ||
| const images = []; | ||
| for (const tag of tags) { | ||
| for (const digest of digests) { | ||
| images.push(`${tag}@${digest}`); | ||
| } | ||
| } | ||
| await exec.getExecOutput('cosign', ['-d', 'sign', '--yes', ...images], { | ||
| ignoreReturnCode: true | ||
| }).then(res => { | ||
| if (res.stderr.length > 0 && res.exitCode != 0) { | ||
| throw new Error(res.stderr); | ||
| } | ||
| }); | ||
| - | ||
| name: Verify signatures | ||
| if: ${{ inputs.push }} | ||
| uses: actions/github-script@v7 | ||
| env: | ||
| INPUT_TAGS: ${{ steps.meta.outputs.tags }} | ||
| INPUT_DIGESTS: ${{ steps.attest.outputs.digests }} | ||
| with: | ||
| script: | | ||
| function getInputList(name) { | ||
| return core.getInput(name) ? core.getInput(name).split(/[\r?\n,]+/).filter(x => x !== '') : []; | ||
| } | ||
| const tags = getInputList('tags'); | ||
| const digests = getInputList('digests'); | ||
| const images = []; | ||
| for (const tag of tags) { | ||
| for (const digest of digests) { | ||
| await core.group(`Verifying ${tag}@${digest}`, async () => { | ||
| await exec.getExecOutput('cosign', ['-d', 'verify', '--certificate-identity-regexp', `^https://github.com/docker/github-builder-experimental/.github/workflows/build.yml.*$`, '--certificate-oidc-issuer', 'https://token.actions.githubusercontent.com', `${tag}@${digest}`], { | ||
crazy-max marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| ignoreReturnCode: true | ||
| }).then(res => { | ||
| if (res.stderr.length > 0 && res.exitCode != 0) { | ||
| core.warning(`Verification failed for ${tag}@${digest}: ${res.stderr}`); | ||
| } | ||
| }); | ||
| }); | ||
| } | ||
| } | ||
| - | ||
| name: Create manifest | ||
| if: ${{ inputs.push }} | ||
| uses: actions/github-script@v7 | ||
| env: | ||
| INPUT_TAGS: ${{ steps.meta.outputs.tags }} | ||
| INPUT_IMAGE-DIGEST: ${{ steps.build.outputs.digest }} | ||
| with: | ||
| script: | | ||
| function getInputList(name) { | ||
| return core.getInput(name) ? core.getInput(name).split(/[\r?\n,]+/).filter(x => x !== '') : []; | ||
| } | ||
|
|
||
| let createArgs = ['buildx', 'imagetools', 'create']; | ||
| for (const tag of getInputList('tags')) { | ||
| createArgs.push('-t', tag); | ||
| } | ||
| createArgs.push(core.getInput('image-digest')); | ||
|
|
||
| await exec.getExecOutput('docker', createArgs, { | ||
| ignoreReturnCode: true | ||
| }).then(res => { | ||
| if (res.stderr.length > 0 && res.exitCode != 0) { | ||
| throw new Error(res.stderr); | ||
| } | ||
| }); | ||
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.
Uh oh!
There was an error while loading. Please reload this page.