diff --git a/.github/workflows/docker-publish.yml b/.github/workflows/docker-publish.yml index bba5295b..6ec5e759 100644 --- a/.github/workflows/docker-publish.yml +++ b/.github/workflows/docker-publish.yml @@ -26,6 +26,7 @@ env: REGISTRY: ghcr.io # github.repository as / IMAGE_NAME: ${{ github.repository }} + MIGRATE_IMAGE_NAME: ${{ github.repository }}-migrate jobs: build: @@ -85,6 +86,19 @@ jobs: type=semver,pattern={{major}} type=raw,value=latest,enable={{is_default_branch}} + - name: Extract Docker metadata (migrate) + id: meta-migrate + uses: docker/metadata-action@96383f45573cb7f253c731d3b3ab81c87ef81934 # v5.0.0 + with: + images: ${{ env.REGISTRY }}/${{ env.MIGRATE_IMAGE_NAME }} + tags: | + type=ref,event=branch + type=ref,event=pr + type=semver,pattern={{version}} + type=semver,pattern={{major}}.{{minor}} + type=semver,pattern={{major}} + type=raw,value=latest,enable={{is_default_branch}} + # Extract version from git tag or ref # Uses git describe to get latest tag + commit hash in SemVer format: 1.2.3+abc1234 - name: Extract version @@ -138,6 +152,22 @@ jobs: cache-from: type=gha cache-to: type=gha,mode=max + - name: Build and push migrate Docker image + id: build-and-push-migrate + uses: docker/build-push-action@0565240e2d4ab88bba5387d719585280857ece09 # v5.0.0 + with: + context: . + file: apps/web/Dockerfile + target: migrate + push: ${{ github.event_name != 'pull_request' }} + platforms: linux/amd64,linux/arm64 + tags: ${{ steps.meta-migrate.outputs.tags }} + labels: ${{ steps.meta-migrate.outputs.labels }} + build-args: | + APP_VERSION=${{ steps.version.outputs.version }} + cache-from: type=gha + cache-to: type=gha,mode=max + # Sign the resulting Docker image digest except on PRs. # This will only write to the public Rekor transparency log when the Docker # repository is public to avoid leaking data. If you would like to publish @@ -152,3 +182,10 @@ jobs: # This step uses the identity token to provision an ephemeral certificate # against the sigstore community Fulcio instance. run: echo "${TAGS}" | xargs -I {} cosign sign --yes {}@${DIGEST} + + - name: Sign the published migrate Docker image + if: ${{ github.event_name != 'pull_request' }} + env: + TAGS: ${{ steps.meta-migrate.outputs.tags }} + DIGEST: ${{ steps.build-and-push-migrate.outputs.digest }} + run: echo "${TAGS}" | xargs -I {} cosign sign --yes {}@${DIGEST}