From b7eddaeac282c7f3d14e761b389bcabc28a13516 Mon Sep 17 00:00:00 2001 From: Linus Gasser Date: Wed, 3 Jul 2024 14:28:35 +0200 Subject: [PATCH] Only pushing if merge on main --- .github/workflows/build-docker.yml | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/.github/workflows/build-docker.yml b/.github/workflows/build-docker.yml index 43cda7b2..dd072fad 100644 --- a/.github/workflows/build-docker.yml +++ b/.github/workflows/build-docker.yml @@ -11,9 +11,9 @@ jobs: build-docker: name: Build D-Voting Docker images runs-on: ubuntu-22.04 - if: '! github.event.pull_request.draft' env: - DockerTag: ${{ (github.ref == 'refs/heads/main') && 'latest' || github.head_ref }} + DockerTag: test + push: ${{ (github.ref == 'refs/heads/main') && 'true' || 'true' }} steps: - name: Checkout @@ -26,10 +26,12 @@ jobs: echo "REACT_APP_VERSION=$(git describe --tags --abbrev=0)" >> $GITHUB_ENV echo "REACT_APP_BUILD=$(git describe --tags)" >> $GITHUB_ENV echo "REACT_APP_BUILD_TIME=$(date)" >> $GITHUB_ENV + echo Pushing is ${{ env.push }} - name: Set up Docker Buildx id: buildx uses: docker/setup-buildx-action@v1 - name: Login to GHCR + if: ${{ env.push == 'true' }} uses: docker/login-action@v1 with: registry: ghcr.io @@ -46,7 +48,7 @@ jobs: REACT_APP_VERSION REACT_APP_BUILD REACT_APP_BUILD_TIME - push: true + push: ${{ env.push }} tags: ghcr.io/c4dt/d-voting-frontend:${{ env.DockerTag }} - name: Build Backend uses: docker/build-push-action@v2 @@ -54,7 +56,7 @@ jobs: context: . file: Dockerfiles/Dockerfile.backend platforms: linux/amd64 - push: true + push: ${{ env.push }} tags: ghcr.io/c4dt/d-voting-backend:${{ env.DockerTag }} - name: Build D-Voting uses: docker/build-push-action@v2 @@ -62,5 +64,5 @@ jobs: context: . file: Dockerfiles/Dockerfile.dela platforms: linux/amd64 - push: true + push: ${{ env.push }} tags: ghcr.io/c4dt/d-voting-dela:${{ env.DockerTag }}