Skip to content

Commit e4200e1

Browse files
committed
ci: build expirable images for pull-requests
1 parent ae2fef4 commit e4200e1

1 file changed

Lines changed: 10 additions & 2 deletions

File tree

.github/workflows/build-images.yaml

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,14 @@ on:
88
branches:
99
- main
1010
- 'release-*'
11+
pull_request:
12+
branches:
13+
- main
14+
- 'release-*'
1115
merge_group:
1216

1317
env:
14-
PUSH: ${{ github.repository_owner == 'jumpstarter-dev' && (github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/') || startsWith(github.ref, 'refs/heads/release-')) }}
18+
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)) }}
1519
REGISTRY: quay.io
1620
QUAY_ORG: quay.io/jumpstarter-dev
1721

@@ -119,6 +123,10 @@ jobs:
119123
uses: docker/metadata-action@v5
120124
with:
121125
images: ${{ env.REGISTRY }}/${{ matrix.image_name }}
126+
tags: |
127+
type=ref,event=pr,prefix=pr-
128+
labels: |
129+
quay.expires-after=${{ github.event_name == 'pull_request' && '7d' || '' }}
122130
123131
- name: Build and push Docker image
124132
id: push
@@ -127,7 +135,7 @@ jobs:
127135
context: ${{ matrix.context }}
128136
file: ${{ matrix.dockerfile }}
129137
push: ${{ env.PUSH }}
130-
tags: ${{ steps.set-tags.outputs.tags }}
138+
tags: ${{ github.event_name == 'pull_request' && steps.meta.outputs.tags || steps.set-tags.outputs.tags }}
131139
labels: ${{ steps.meta.outputs.labels }}
132140
platforms: linux/amd64,linux/arm64
133141
cache-from: type=gha

0 commit comments

Comments
 (0)