From 54415ca13cb7750bdb1c56bf682e18bad6b2adc4 Mon Sep 17 00:00:00 2001 From: Zak <34372536+ZakShearman@users.noreply.github.com> Date: Mon, 4 Nov 2024 12:53:33 +0000 Subject: [PATCH] feat: don't deploy on PRs, change PR docker image naming scheme --- .github/workflows/build.yaml | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 7e77b49..c78f5c5 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -59,11 +59,11 @@ jobs: run: | tag_prefix="ghcr.io/emortalmc/${{ matrix.service }}" tags="" - - if [[ "${{ github.ref }}" == "refs/heads/main" ]]; then + if [[ "${{ github.event_name }}" == "pull_request" ]]; then + short_sha=$(echo "${{ github.event.pull_request.head.sha }}" | cut -c1-7) + tags="$tag_prefix:pr-${{ github.event.number }}-$short_sha" + elif [[ "${{ github.ref }}" == "refs/heads/main" ]]; then tags="$tag_prefix:${{ github.sha }},$tag_prefix:latest" - elif [[ "${{ github.event_name }}" == "pull_request" ]]; then - tags="$tag_prefix:pr-${{ github.event.number }},$tag_prefix:${{github.event.pull_request.head.sha}}" fi echo "DOCKER_TAGS=$tags" >> "$GITHUB_ENV" @@ -90,6 +90,7 @@ jobs: deploy: needs: [build-and-publish, detect-services] runs-on: ubuntu-latest + if: github.event_name != 'pull_request' && github.ref == 'refs/heads/main' # Only run on main branch, non-PR pushes env: SERVICES: ${{ needs.detect-services.outputs.services }} steps: