Skip to content

Commit e0ac1c9

Browse files
committed
ci: allow conditional container push from labeled pull requests
1 parent 590e55a commit e0ac1c9

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

.github/workflows/docker_image.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ concurrency:
1616
env:
1717
REGISTRY: ghcr.io
1818
IMAGE_NAME: ${{ github.repository }}
19+
# Set to 'true' to allow pushing container from pull requests with the label 'push-container'
20+
PUSH_FROM_PR: ${{ github.event_name == 'pull_request' && contains(github.event.pull_request.labels.*.name, 'push-container') }}
1921

2022
jobs:
2123
docker-build:
@@ -67,14 +69,14 @@ jobs:
6769
with:
6870
context: .
6971
platforms: linux/amd64, linux/arm64
70-
push: ${{ github.event_name != 'pull_request' }}
72+
push: ${{ github.event_name != 'pull_request' || env.PUSH_FROM_PR == 'true' }}
7173
tags: ${{ steps.meta.outputs.tags }}
7274
labels: ${{ steps.meta.outputs.labels }}
7375
cache-from: type=gha
7476
cache-to: type=gha,mode=max
7577

7678
- name: Generate artifact attestation
77-
if: github.event_name != 'pull_request'
79+
if: github.event_name != 'pull_request' || env.PUSH_FROM_PR == 'true'
7880
uses: actions/attest-build-provenance@v2
7981
with:
8082
subject-name: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME}}

0 commit comments

Comments
 (0)