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: