Skip to content

Commit 3c94b94

Browse files
authored
ci: fix labeled pr (#464)
1 parent 6d9d833 commit 3c94b94

File tree

1 file changed

+26
-2
lines changed

1 file changed

+26
-2
lines changed

.github/workflows/build-and-test.yml

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,13 @@ permissions: {}
2121
# - Groups runs by PR head ref
2222
# - Cancels in-progress runs when new commits are pushed
2323
concurrency:
24-
group: build-and-test-${{ github.head_ref || github.run_id }}
24+
group: >-
25+
build-and-test-${{ github.head_ref || github.run_id }}-${{
26+
github.event.action == 'labeled' &&
27+
startsWith(github.event.label.name, 'pr-preview-') &&
28+
'label-pr-preview' ||
29+
'main'
30+
}}
2531
cancel-in-progress: true
2632

2733
jobs:
@@ -30,6 +36,14 @@ jobs:
3036
############################################################################
3137
docker-build:
3238
name: build-and-test/docker-build
39+
if: >-
40+
github.event_name == 'pull_request' &&
41+
(
42+
github.event.action == 'opened' ||
43+
github.event.action == 'synchronize' ||
44+
github.event.action == 'reopened' ||
45+
(github.event.action == 'labeled' && startsWith(github.event.label.name, 'pr-preview-'))
46+
)
3347
permissions:
3448
actions: read # Required to read workflow run information
3549
contents: write # Required to checkout repository code
@@ -54,7 +68,9 @@ jobs:
5468
kind-testing:
5569
name: build-and-test/kind-testing
5670
needs: [docker-build]
57-
if: github.event_name == 'pull_request' && (github.event.action == 'opened' || github.event.action == 'synchronize' || github.event.action == 'reopened')
71+
if: >-
72+
github.event_name == 'pull_request' &&
73+
(github.event.action == 'opened' || github.event.action == 'synchronize' || github.event.action == 'reopened')
5874
permissions:
5975
actions: read # Required to read workflow run information
6076
contents: write # Required for nested docker-build job (even if it doesn't run)
@@ -84,6 +100,14 @@ jobs:
84100
check-pr-preview-labels:
85101
name: build-and-test/check-labels
86102
runs-on: ubuntu-latest
103+
if: >-
104+
github.event_name == 'pull_request' &&
105+
(
106+
github.event.action == 'opened' ||
107+
github.event.action == 'synchronize' ||
108+
github.event.action == 'reopened' ||
109+
(github.event.action == 'labeled' && startsWith(github.event.label.name, 'pr-preview-'))
110+
)
87111
outputs:
88112
should_deploy: ${{ steps.check.outputs.should_deploy }}
89113
deployment_type: ${{ steps.check.outputs.deployment_type }}

0 commit comments

Comments
 (0)