|
7 | 7 | - dev-[0-9]+.[0-9]+.[0-9]+
|
8 | 8 | tags:
|
9 | 9 | - v*
|
| 10 | + pull_request: |
| 11 | + types: |
| 12 | + # publish images for PRs labeled "publish" whenever changed/labeled |
| 13 | + [opened, reopened, synchronize, labeled] |
10 | 14 | workflow_dispatch:
|
11 | 15 |
|
12 | 16 | env:
|
13 | 17 | REGISTRY: ghcr.io
|
14 | 18 | OWNER: nasa-ammos
|
15 | 19 | IS_RELEASE: ${{ startsWith(github.ref, 'refs/tags/v') }}
|
| 20 | + SHOULD_PUBLISH_IMAGES: ${{ (github.event_name != 'pull_request') || contains(github.event.pull_request.labels.*.name, 'publish') }} |
| 21 | + SHOULD_PUBLISH_DEPLOYMENT: ${{ (github.event_name != 'pull_request') }} |
16 | 22 |
|
17 | 23 | jobs:
|
18 | 24 | init:
|
19 | 25 | runs-on: ubuntu-latest
|
20 | 26 | permissions:
|
21 | 27 | contents: read
|
| 28 | + outputs: |
| 29 | + # set these as outputs to make available later, since `env` context isn't available in `jobs.if` |
| 30 | + SHOULD_PUBLISH_IMAGES: ${{ env.SHOULD_PUBLISH_IMAGES }} |
| 31 | + SHOULD_PUBLISH_DEPLOYMENT: ${{ env.SHOULD_PUBLISH_DEPLOYMENT }} |
22 | 32 | steps:
|
23 | 33 | - uses: actions/checkout@v4
|
24 | 34 |
|
|
34 | 44 | containers:
|
35 | 45 | runs-on: ubuntu-latest
|
36 | 46 | needs: init
|
| 47 | + if: needs.init.outputs.SHOULD_PUBLISH_IMAGES == 'true' |
37 | 48 | permissions:
|
38 | 49 | contents: read
|
39 | 50 | packages: write
|
|
63 | 74 | file: docker/Dockerfile.postgres
|
64 | 75 | name: ${{ matrix.components.image }}
|
65 | 76 | steps:
|
| 77 | + - name: Log SHOULD_PUBLISH_IMAGES |
| 78 | + run: echo ${{ needs.init.outputs.SHOULD_PUBLISH_IMAGES }} |
| 79 | + |
66 | 80 | - uses: actions/checkout@v4
|
67 | 81 |
|
68 | 82 | - uses: actions/setup-java@v4
|
@@ -119,6 +133,7 @@ jobs:
|
119 | 133 | scan:
|
120 | 134 | runs-on: ubuntu-latest
|
121 | 135 | needs: containers
|
| 136 | + if: needs.init.outputs.SHOULD_PUBLISH_IMAGES == 'true' |
122 | 137 | strategy:
|
123 | 138 | matrix:
|
124 | 139 | image:
|
@@ -155,6 +170,7 @@ jobs:
|
155 | 170 | name: gradle publish
|
156 | 171 | runs-on: ubuntu-latest
|
157 | 172 | needs: init
|
| 173 | + if: needs.init.outputs.SHOULD_PUBLISH_DEPLOYMENT == 'true' |
158 | 174 | permissions:
|
159 | 175 | contents: read
|
160 | 176 | packages: write
|
|
0 commit comments