diff --git a/.github/workflows/docker-publish.yml b/.github/workflows/docker-publish.yml index cef3461..3809814 100644 --- a/.github/workflows/docker-publish.yml +++ b/.github/workflows/docker-publish.yml @@ -25,12 +25,14 @@ jobs: uses: docker/setup-buildx-action@v3 - name: Log in to Docker Hub + if: github.event_name != 'pull_request' uses: docker/login-action@v3 with: username: ${{ secrets.DOCKER_USERNAME }} password: ${{ secrets.DOCKER_PASSWORD }} - name: Extract metadata for Backend + if: github.event_name != 'pull_request' id: meta-backend uses: docker/metadata-action@v5 with: @@ -43,11 +45,20 @@ jobs: type=semver,pattern={{major}} type=sha,prefix= - - name: Build and push Backend + - name: Build Backend image for PR + if: github.event_name == 'pull_request' uses: docker/build-push-action@v5 with: context: ./backend - push: ${{ github.event_name != 'pull_request' }} + push: false + tags: flclouds-backend:pr-${{ github.event.pull_request.number }} + + - name: Build and push Backend + if: github.event_name != 'pull_request' + uses: docker/build-push-action@v5 + with: + context: ./backend + push: true tags: ${{ steps.meta-backend.outputs.tags }} labels: ${{ steps.meta-backend.outputs.labels }} @@ -62,12 +73,14 @@ jobs: uses: docker/setup-buildx-action@v3 - name: Log in to Docker Hub + if: github.event_name != 'pull_request' uses: docker/login-action@v3 with: username: ${{ secrets.DOCKER_USERNAME }} password: ${{ secrets.DOCKER_PASSWORD }} - name: Extract metadata for Frontend + if: github.event_name != 'pull_request' id: meta-frontend uses: docker/metadata-action@v5 with: @@ -80,10 +93,19 @@ jobs: type=semver,pattern={{major}} type=sha,prefix= - - name: Build and push Frontend + - name: Build Frontend image for PR + if: github.event_name == 'pull_request' uses: docker/build-push-action@v5 with: context: ./frontend - push: ${{ github.event_name != 'pull_request' }} + push: false + tags: flclouds-frontend:pr-${{ github.event.pull_request.number }} + + - name: Build and push Frontend + if: github.event_name != 'pull_request' + uses: docker/build-push-action@v5 + with: + context: ./frontend + push: true tags: ${{ steps.meta-frontend.outputs.tags }} labels: ${{ steps.meta-frontend.outputs.labels }}