ci: compute docker metadata without api lookup
This commit is contained in:
+46
-12
@@ -237,19 +237,53 @@ jobs:
|
|||||||
username: ${{ github.actor }}
|
username: ${{ github.actor }}
|
||||||
password: ${{ secrets.GITHUB_TOKEN }}
|
password: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
|
||||||
- name: Extract metadata for Docker
|
- name: Compute Docker metadata
|
||||||
id: meta
|
id: meta
|
||||||
uses: docker/metadata-action@v5
|
env:
|
||||||
with:
|
DEFAULT_BRANCH: ${{ github.event.repository.default_branch }}
|
||||||
images: ghcr.io/${{ github.repository }}
|
EVENT_NAME: ${{ github.event_name }}
|
||||||
tags: |
|
REF_NAME: ${{ github.ref_name }}
|
||||||
type=ref,event=branch
|
REF_TYPE: ${{ github.ref_type }}
|
||||||
type=ref,event=tag
|
RELEASE_TAG: ${{ github.event.inputs.release_tag }}
|
||||||
type=semver,pattern={{version}}
|
PROMOTE_STABLE: ${{ github.event.inputs.promote_stable }}
|
||||||
type=sha,prefix=
|
run: |
|
||||||
type=raw,value=${{ github.event.inputs.release_tag }},enable=${{ github.event_name == 'workflow_dispatch' && github.event.inputs.release_tag != '' }}
|
IMAGE="ghcr.io/$(echo "${GITHUB_REPOSITORY}" | tr '[:upper:]' '[:lower:]')"
|
||||||
type=raw,value=stable,enable=${{ startsWith(github.ref, 'refs/tags/v') || github.event.inputs.promote_stable == 'true' }}
|
SHORT_SHA="$(echo "${GITHUB_SHA}" | cut -c1-7)"
|
||||||
type=raw,value=latest,enable={{is_default_branch}}
|
TAGS=("${IMAGE}:${SHORT_SHA}")
|
||||||
|
|
||||||
|
if [ "${REF_TYPE}" = "branch" ]; then
|
||||||
|
SAFE_BRANCH="$(echo "${REF_NAME}" | tr '/:@' '---')"
|
||||||
|
TAGS+=("${IMAGE}:${SAFE_BRANCH}")
|
||||||
|
if [ "${REF_NAME}" = "${DEFAULT_BRANCH}" ]; then
|
||||||
|
TAGS+=("${IMAGE}:latest")
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ "${REF_TYPE}" = "tag" ]; then
|
||||||
|
TAGS+=("${IMAGE}:${REF_NAME}")
|
||||||
|
if [[ "${REF_NAME}" =~ ^v[0-9] ]]; then
|
||||||
|
TAGS+=("${IMAGE}:${REF_NAME#v}")
|
||||||
|
TAGS+=("${IMAGE}:stable")
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ "${EVENT_NAME}" = "workflow_dispatch" ] && [ -n "${RELEASE_TAG}" ]; then
|
||||||
|
TAGS+=("${IMAGE}:${RELEASE_TAG}")
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ "${PROMOTE_STABLE}" = "true" ]; then
|
||||||
|
TAGS+=("${IMAGE}:stable")
|
||||||
|
fi
|
||||||
|
|
||||||
|
{
|
||||||
|
echo "tags<<EOF"
|
||||||
|
printf '%s\n' "${TAGS[@]}" | sort -u
|
||||||
|
echo "EOF"
|
||||||
|
echo "labels<<EOF"
|
||||||
|
echo "org.opencontainers.image.source=https://github.com/${GITHUB_REPOSITORY}"
|
||||||
|
echo "org.opencontainers.image.revision=${GITHUB_SHA}"
|
||||||
|
echo "EOF"
|
||||||
|
} >> "$GITHUB_OUTPUT"
|
||||||
|
|
||||||
- name: Build and push Docker image
|
- name: Build and push Docker image
|
||||||
uses: docker/build-push-action@v6
|
uses: docker/build-push-action@v6
|
||||||
|
|||||||
Reference in New Issue
Block a user