This commit is contained in:
2025-11-09 19:26:24 +01:00
parent 6d0d453aa1
commit cbdb180423
+21 -14
View File
@@ -6,8 +6,8 @@ on:
- main - main
- staging - staging
- dev - dev
tags: tags:
- '*' - '*'
jobs: jobs:
docker: docker:
@@ -65,6 +65,7 @@ jobs:
echo "base_tag=$tag" >> "$GITHUB_OUTPUT" echo "base_tag=$tag" >> "$GITHUB_OUTPUT"
- name: Login to local registry - name: Login to local registry
if: ${{ vars.REGISTRY_URL != '' }}
uses: docker/login-action@v2 uses: docker/login-action@v2
with: with:
registry: ${{ vars.REGISTRY_URL }} registry: ${{ vars.REGISTRY_URL }}
@@ -75,8 +76,8 @@ jobs:
uses: docker/login-action@v2 uses: docker/login-action@v2
with: with:
registry: ghcr.io registry: ghcr.io
username: ${{ vars.GHCR_USERNAME }} username: ${{ github.actor }}
password: ${{ secrets.GHCR_PASSWORD }} password: ${{ github.token }}
- name: Set up QEMU - name: Set up QEMU
uses: docker/setup-qemu-action@v3 uses: docker/setup-qemu-action@v3
@@ -106,25 +107,31 @@ jobs:
BASE_TAG: ${{ steps.compute_tag.outputs.base_tag }} BASE_TAG: ${{ steps.compute_tag.outputs.base_tag }}
GIT_SHA: ${{ github.sha }} GIT_SHA: ${{ github.sha }}
BRANCH_ALIAS: ${{ steps.branch_alias.outputs.alias }} BRANCH_ALIAS: ${{ steps.branch_alias.outputs.alias }}
shell: bash
run: | run: |
tags=""
if [ -n "${REGISTRY_URL}" ]; then if [ -n "${REGISTRY_URL}" ]; then
repo_tag="${REGISTRY_URL}/${REPO_NAME}-${SERVICE}" repo_tag="${REGISTRY_URL}/${REPO_NAME}-${SERVICE}"
else tags="${tags}${repo_tag}:${BASE_TAG}\n${repo_tag}:${GIT_SHA}"
repo_tag="${REPO_NAME}-${SERVICE}"
fi fi
ghcr_tag="ghcr.io/papercrate-dms/${REPO_NAME}-${SERVICE}"
tags="${repo_tag}:${BASE_TAG}\n${repo_tag}:${GIT_SHA}\n${ghcr_tag}:${BASE_TAG}\n${ghcr_tag}:${GIT_SHA}" ghcr_tag="ghcr.io/papercrate-dms/${REPO_NAME}-${SERVICE}"
if [ -n "${tags}" ]; then
tags="${tags}\n"
fi
tags="${tags}${ghcr_tag}:${BASE_TAG}\n${ghcr_tag}:${GIT_SHA}"
if [ -n "${BRANCH_ALIAS}" ]; then if [ -n "${BRANCH_ALIAS}" ]; then
tags="${tags}\n${repo_tag}:${BRANCH_ALIAS}\n${ghcr_tag}:${BRANCH_ALIAS}" if [ -n "${REGISTRY_URL}" ]; then
tags="${tags}\n${repo_tag}:${BRANCH_ALIAS}"
fi
tags="${tags}\n${ghcr_tag}:${BRANCH_ALIAS}"
fi fi
{ export TAGS="${tags}"
echo "tags<<'EOF'"
echo "${tags}" python -c 'import os; tags=[t.strip() for t in os.environ["TAGS"].split("\\n") if t.strip()]; print("tags=" + ",".join(tags))' | tee -a "$GITHUB_OUTPUT"
echo EOF
} >> "$GITHUB_OUTPUT"
- name: Build and Push ${{ matrix.service }} Image - name: Build and Push ${{ matrix.service }} Image
uses: docker/build-push-action@v6 uses: docker/build-push-action@v6