Add build number and semver tags to CI images
All checks were successful
Build & Deploy / build-and-deploy (push) Successful in 26s

Every push to main tags with latest + build-N (run number).
Pushing a git tag like v1.0.0 also tags the image with that version.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-04-13 19:15:02 +00:00
parent fdbf22c699
commit 437472be85

View File

@@ -3,6 +3,7 @@ name: Build & Deploy
on: on:
push: push:
branches: [main] branches: [main]
tags: ["v*"]
env: env:
REGISTRY: gitea.nautilus.marcusgroup.org REGISTRY: gitea.nautilus.marcusgroup.org
@@ -21,13 +22,34 @@ jobs:
docker login ${{ env.REGISTRY }} \ docker login ${{ env.REGISTRY }} \
-u "${{ secrets.REGISTRY_USER }}" --password-stdin -u "${{ secrets.REGISTRY_USER }}" --password-stdin
- name: Build and push image - name: Build and tag image
run: | run: |
TAG="${{ env.REGISTRY }}/${{ env.IMAGE }}:latest" BASE="${{ env.REGISTRY }}/${{ env.IMAGE }}"
SHA_TAG="${{ env.REGISTRY }}/${{ env.IMAGE }}:${{ github.sha }}" TAGS="-t ${BASE}:latest -t ${BASE}:build-${{ github.run_number }}"
docker build -t "$TAG" -t "$SHA_TAG" .
docker push "$TAG" # If this is a version tag (v*), add the semver tag
docker push "$SHA_TAG" REF="${{ github.ref }}"
if [[ "$REF" == refs/tags/v* ]]; then
VERSION="${REF#refs/tags/}"
TAGS="$TAGS -t ${BASE}:${VERSION}"
echo "📦 Release: ${VERSION}"
fi
echo "🏗️ Building with tags: build-${{ github.run_number }}, latest"
docker build $TAGS .
- name: Push image
run: |
BASE="${{ env.REGISTRY }}/${{ env.IMAGE }}"
docker push "${BASE}:latest"
docker push "${BASE}:build-${{ github.run_number }}"
REF="${{ github.ref }}"
if [[ "$REF" == refs/tags/v* ]]; then
VERSION="${REF#refs/tags/}"
docker push "${BASE}:${VERSION}"
echo "✅ Pushed ${VERSION}"
fi
- name: Trigger Coolify redeploy - name: Trigger Coolify redeploy
run: | run: |