Update docker-publish.yml

This commit is contained in:
yojoshb 2024-04-11 01:54:51 -05:00 committed by GitHub
parent 472db9f8a9
commit d81573e7bc
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -1,9 +1,6 @@
name: DockerBuild
# This workflow uses actions that are not certified by GitHub.
# They are provided by a third-party and are governed by
# separate terms of service, privacy policy, and support
# documentation.
# They are provided by a third-party and are governed by separate terms of service, privacy policy, and support documentation.
on:
workflow_dispatch:
@ -34,19 +31,14 @@ jobs:
steps:
- name: Checkout repository
uses: actions/checkout@v4
# Install the cosign tool except on PR
# https://github.com/sigstore/cosign-installer
# Install the cosign tool except on PR https://github.com/sigstore/cosign-installer
- name: Install cosign
if: github.event_name != 'pull_request'
uses: sigstore/cosign-installer@v3.5.0
uses: sigstore/cosign-installer@v3.5.0
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Setup Docker buildx
uses: docker/setup-buildx-action@v3
- name: Log into registry ${{ env.REGISTRY }}
if: github.event_name != 'pull_request'
uses: docker/login-action@v3
@ -54,14 +46,13 @@ jobs:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract metadata
id: meta
uses: docker/metadata-action@v4
with:
flavor: latest=true
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: type=sha,format=long
- name: Build and push Docker image
id: build-and-push
uses: docker/build-push-action@v5
@ -71,13 +62,27 @@ jobs:
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
# Sign the resulting Docker image digest except on PRs.
# https://github.com/sigstore/cosign
- name: Sign the published Docker image
# Sign the resulting Docker image digest except on PRs. https://github.com/sigstore/cosign
- name: Sign image with a key
if: ${{ github.event_name != 'pull_request' }}
run: |
images=""
for tag in ${TAGS}; do
images+="${tag}@${DIGEST} "
done
cosign sign --yes --key env://COSIGN_PRIVATE_KEY ${images}
env:
COSIGN_EXPERIMENTAL: "true"
# This step uses the identity token to provision an ephemeral certificate against the sigstore community Fulcio instance.
run: echo "${{ steps.meta.outputs.tags }}" | xargs -I {} cosign sign {}@${{ steps.build-and-push.outputs.digest }}
TAGS: ${{ steps.meta.outputs.tags }}
COSIGN_PRIVATE_KEY: ${{ secrets.COSIGN_PRIVATE_KEY }}
COSIGN_PASSWORD: ${{ secrets.COSIGN_PASSWORD }}
DIGEST: ${{ steps.build-and-push.outputs.digest }}
- name: Sign the images with GitHub OIDC Token
env:
DIGEST: ${{ steps.build-and-push.outputs.digest }}
TAGS: ${{ steps.meta.outputs.tags }}
run: |
images=""
for tag in ${TAGS}; do
images+="${tag}@${DIGEST} "
done
cosign sign --yes ${images}