diff --git a/.github/workflows/build-images.yaml b/.github/workflows/build-images.yaml index 7dd9b3614..59d807676 100644 --- a/.github/workflows/build-images.yaml +++ b/.github/workflows/build-images.yaml @@ -8,15 +8,21 @@ on: branches: - main - 'release-*' + pull_request: + types: [opened, synchronize, reopened, labeled] + branches: + - main + - 'release-*' merge_group: env: - PUSH: ${{ github.repository_owner == 'jumpstarter-dev' && (github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/') || startsWith(github.ref, 'refs/heads/release-')) }} + PUSH: ${{ github.repository_owner == 'jumpstarter-dev' && (github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/') || startsWith(github.ref, 'refs/heads/release-') || (github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository)) }} REGISTRY: quay.io QUAY_ORG: quay.io/jumpstarter-dev jobs: build-and-push-image: + if: github.event_name != 'pull_request' || contains(github.event.pull_request.labels.*.name, 'build-pr-images') runs-on: ubuntu-latest permissions: contents: read @@ -119,6 +125,10 @@ jobs: uses: docker/metadata-action@v5 with: images: ${{ env.REGISTRY }}/${{ matrix.image_name }} + tags: | + type=ref,event=pr,prefix=pr- + labels: | + quay.expires-after=${{ github.event_name == 'pull_request' && '7d' || '' }} - name: Build and push Docker image id: push @@ -127,7 +137,7 @@ jobs: context: ${{ matrix.context }} file: ${{ matrix.dockerfile }} push: ${{ env.PUSH }} - tags: ${{ steps.set-tags.outputs.tags }} + tags: ${{ github.event_name == 'pull_request' && steps.meta.outputs.tags || steps.set-tags.outputs.tags }} labels: ${{ steps.meta.outputs.labels }} platforms: linux/amd64,linux/arm64 cache-from: type=gha