This commit is contained in:
bkellam 2024-09-05 19:08:01 -07:00
parent 4bf1a3e61d
commit 6751b20fca

View file

@ -18,6 +18,7 @@ on:
env: env:
# Use docker.io for Docker Hub if empty # Use docker.io for Docker Hub if empty
REGISTRY: ghcr.io REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
jobs: jobs:
@ -36,19 +37,13 @@ jobs:
with: with:
submodules: 'true' submodules: 'true'
- name: Prepare # Extract metadata (tags, labels) for Docker
id: prep # https://github.com/docker/metadata-action
run: | - name: Extract Docker metadata
DOCKER_IMAGE=${REGISTRY}/${{ github.repository_owner }}/sourcebot id: meta
VERSION=latest uses: docker/metadata-action@v5
if [[ $GITHUB_REF == refs/tags/* ]]; then with:
VERSION=${GITHUB_REF#refs/tags/v} images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
fi
TAGS="${DOCKER_IMAGE}:${VERSION}"
if [[ $VERSION =~ ^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$ ]]; then
TAGS="$TAGS,${DOCKER_IMAGE}:latest"
fi
echo ::set-output name=tags::${TAGS}
# Install the cosign tool except on PR # Install the cosign tool except on PR
# https://github.com/sigstore/cosign-installer # https://github.com/sigstore/cosign-installer
@ -79,7 +74,8 @@ jobs:
push: ${{ github.event_name != 'pull_request' }} push: ${{ github.event_name != 'pull_request' }}
platforms: linux/amd64,linux/arm64 platforms: linux/amd64,linux/arm64
file: ./Dockerfile file: ./Dockerfile
tags: ${{ steps.prep.outputs.tags }} tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
# Sign the resulting Docker image digest except on PRs. # Sign the resulting Docker image digest except on PRs.
# This will only write to the public Rekor transparency log when the Docker # This will only write to the public Rekor transparency log when the Docker