From 60bcf7d96466be8a302e8d3727f005658ac3b4f3 Mon Sep 17 00:00:00 2001 From: Christian Krakau-Louis Date: Fri, 28 Mar 2025 20:54:04 +0100 Subject: [PATCH] Update docker-build.yaml --- .github/workflows/docker-build.yaml | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/.github/workflows/docker-build.yaml b/.github/workflows/docker-build.yaml index eba37419..c66c2e66 100644 --- a/.github/workflows/docker-build.yaml +++ b/.github/workflows/docker-build.yaml @@ -9,6 +9,9 @@ on: branches: - main - develop + tags: + - 'v*' + - '[0-9]+.*' pull_request: branches: - main @@ -16,6 +19,7 @@ on: jobs: build: runs-on: ubuntu-latest + steps: - name: Checkout Code uses: actions/checkout@v3 @@ -36,19 +40,23 @@ jobs: username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} - - name: Build and Push + - name: Extract Git Tag (if applicable) + if: startsWith(github.ref, 'refs/tags/') + run: echo "VERSION=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV + + - name: Build and Push Docker Image uses: docker/build-push-action@v4 with: - # Specify target platforms platforms: linux/amd64 context: . file: Dockerfile push: true + cache-from: type=gha + cache-to: type=gha,mode=max tags: | christianlouis/document-processor:latest christianlouis/document-processor:${{ github.sha }} ghcr.io/${{ github.repository_owner }}/document-processor:latest ghcr.io/${{ github.repository_owner }}/document-processor:${{ github.sha }} - # Cache options (optional) - cache-from: type=gha - cache-to: type=gha,mode=max + ${{ startsWith(github.ref, 'refs/tags/') && format('christianlouis/document-processor:{0}', env.VERSION) || '' }} + ${{ startsWith(github.ref, 'refs/tags/') && format('ghcr.io/{0}/document-processor:{1}', github.repository_owner, env.VERSION) || '' }}