Skip to content

Commit a4daa5d

Browse files
authored
Merge pull request #298 from per1234/add-release-branch-triggers
Expand workflow support for "trunk-based development" strategy
2 parents d92d6ac + bc3a0e3 commit a4daa5d

14 files changed

+368
-0
lines changed

.github/workflows/check-general-formatting-task.yml

+26
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ name: Check General Formatting
33

44
# See: https://docs.github.com/actions/using-workflows/events-that-trigger-workflows
55
on:
6+
create:
67
push:
78
pull_request:
89
schedule:
@@ -12,7 +13,32 @@ on:
1213
repository_dispatch:
1314

1415
jobs:
16+
run-determination:
17+
runs-on: ubuntu-latest
18+
outputs:
19+
result: ${{ steps.determination.outputs.result }}
20+
steps:
21+
- name: Determine if the rest of the workflow should run
22+
id: determination
23+
run: |
24+
RELEASE_BRANCH_REGEX="refs/heads/[0-9]+.[0-9]+.x"
25+
# The `create` event trigger doesn't support `branches` filters, so it's necessary to use Bash instead.
26+
if [[
27+
"${{ github.event_name }}" != "create" ||
28+
"${{ github.ref }}" =~ $RELEASE_BRANCH_REGEX
29+
]]; then
30+
# Run the other jobs.
31+
RESULT="true"
32+
else
33+
# There is no need to run the other jobs.
34+
RESULT="false"
35+
fi
36+
37+
echo "result=$RESULT" >> $GITHUB_OUTPUT
38+
1539
check:
40+
needs: run-determination
41+
if: needs.run-determination.outputs.result == 'true'
1642
runs-on: ubuntu-latest
1743

1844
steps:

.github/workflows/check-javascript-task.yml

+26
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ env:
77

88
# See: https://docs.github.com/actions/using-workflows/events-that-trigger-workflows
99
on:
10+
create:
1011
push:
1112
paths:
1213
- ".github/workflows/check-javascript-task.ya?ml"
@@ -32,7 +33,32 @@ permissions:
3233
contents: read
3334

3435
jobs:
36+
run-determination:
37+
runs-on: ubuntu-latest
38+
outputs:
39+
result: ${{ steps.determination.outputs.result }}
40+
steps:
41+
- name: Determine if the rest of the workflow should run
42+
id: determination
43+
run: |
44+
RELEASE_BRANCH_REGEX="refs/heads/[0-9]+.[0-9]+.x"
45+
# The `create` event trigger doesn't support `branches` filters, so it's necessary to use Bash instead.
46+
if [[
47+
"${{ github.event_name }}" != "create" ||
48+
"${{ github.ref }}" =~ $RELEASE_BRANCH_REGEX
49+
]]; then
50+
# Run the other jobs.
51+
RESULT="true"
52+
else
53+
# There is no need to run the other jobs.
54+
RESULT="false"
55+
fi
56+
57+
echo "result=$RESULT" >> $GITHUB_OUTPUT
58+
3559
check:
60+
needs: run-determination
61+
if: needs.run-determination.outputs.result == 'true'
3662
runs-on: ubuntu-latest
3763

3864
steps:

.github/workflows/check-npm-task.yml

+28
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ env:
77

88
# See: https://docs.github.com/en/actions/reference/events-that-trigger-workflows
99
on:
10+
create:
1011
push:
1112
paths:
1213
- ".github/workflows/check-npm-task.ya?ml"
@@ -29,7 +30,32 @@ permissions:
2930
contents: read
3031

3132
jobs:
33+
run-determination:
34+
runs-on: ubuntu-latest
35+
outputs:
36+
result: ${{ steps.determination.outputs.result }}
37+
steps:
38+
- name: Determine if the rest of the workflow should run
39+
id: determination
40+
run: |
41+
RELEASE_BRANCH_REGEX="refs/heads/[0-9]+.[0-9]+.x"
42+
# The `create` event trigger doesn't support `branches` filters, so it's necessary to use Bash instead.
43+
if [[
44+
"${{ github.event_name }}" != "create" ||
45+
"${{ github.ref }}" =~ $RELEASE_BRANCH_REGEX
46+
]]; then
47+
# Run the other jobs.
48+
RESULT="true"
49+
else
50+
# There is no need to run the other jobs.
51+
RESULT="false"
52+
fi
53+
54+
echo "result=$RESULT" >> $GITHUB_OUTPUT
55+
3256
validate:
57+
needs: run-determination
58+
if: needs.run-determination.outputs.result == 'true'
3359
runs-on: ubuntu-latest
3460

3561
steps:
@@ -51,6 +77,8 @@ jobs:
5177
run: task --silent npm:validate
5278

5379
check-sync:
80+
needs: run-determination
81+
if: needs.run-determination.outputs.result == 'true'
5482
runs-on: ubuntu-latest
5583

5684
steps:

.github/workflows/check-prettier-formatting-task.yml

+26
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ env:
77

88
# See: https://docs.github.com/actions/using-workflows/events-that-trigger-workflows
99
on:
10+
create:
1011
push:
1112
paths:
1213
- ".github/workflows/check-prettier-formatting-task.ya?ml"
@@ -206,7 +207,32 @@ on:
206207
repository_dispatch:
207208

208209
jobs:
210+
run-determination:
211+
runs-on: ubuntu-latest
212+
outputs:
213+
result: ${{ steps.determination.outputs.result }}
214+
steps:
215+
- name: Determine if the rest of the workflow should run
216+
id: determination
217+
run: |
218+
RELEASE_BRANCH_REGEX="refs/heads/[0-9]+.[0-9]+.x"
219+
# The `create` event trigger doesn't support `branches` filters, so it's necessary to use Bash instead.
220+
if [[
221+
"${{ github.event_name }}" != "create" ||
222+
"${{ github.ref }}" =~ $RELEASE_BRANCH_REGEX
223+
]]; then
224+
# Run the other jobs.
225+
RESULT="true"
226+
else
227+
# There is no need to run the other jobs.
228+
RESULT="false"
229+
fi
230+
231+
echo "result=$RESULT" >> $GITHUB_OUTPUT
232+
209233
check:
234+
needs: run-determination
235+
if: needs.run-determination.outputs.result == 'true'
210236
runs-on: ubuntu-latest
211237

212238
steps:

.github/workflows/check-taskfiles.yml

+26
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ env:
77

88
# See: https://docs.github.com/actions/using-workflows/events-that-trigger-workflows
99
on:
10+
create:
1011
push:
1112
paths:
1213
- ".github/workflows/check-taskfiles.ya?ml"
@@ -26,8 +27,33 @@ on:
2627
repository_dispatch:
2728

2829
jobs:
30+
run-determination:
31+
runs-on: ubuntu-latest
32+
outputs:
33+
result: ${{ steps.determination.outputs.result }}
34+
steps:
35+
- name: Determine if the rest of the workflow should run
36+
id: determination
37+
run: |
38+
RELEASE_BRANCH_REGEX="refs/heads/[0-9]+.[0-9]+.x"
39+
# The `create` event trigger doesn't support `branches` filters, so it's necessary to use Bash instead.
40+
if [[
41+
"${{ github.event_name }}" != "create" ||
42+
"${{ github.ref }}" =~ $RELEASE_BRANCH_REGEX
43+
]]; then
44+
# Run the other jobs.
45+
RESULT="true"
46+
else
47+
# There is no need to run the other jobs.
48+
RESULT="false"
49+
fi
50+
51+
echo "result=$RESULT" >> $GITHUB_OUTPUT
52+
2953
validate:
3054
name: Validate ${{ matrix.file }}
55+
needs: run-determination
56+
if: needs.run-determination.outputs.result == 'true'
3157
runs-on: ubuntu-latest
3258

3359
strategy:

.github/workflows/spell-check-task.yml

+26
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ env:
77

88
# See: https://docs.github.com/actions/using-workflows/events-that-trigger-workflows
99
on:
10+
create:
1011
push:
1112
pull_request:
1213
schedule:
@@ -16,7 +17,32 @@ on:
1617
repository_dispatch:
1718

1819
jobs:
20+
run-determination:
21+
runs-on: ubuntu-latest
22+
outputs:
23+
result: ${{ steps.determination.outputs.result }}
24+
steps:
25+
- name: Determine if the rest of the workflow should run
26+
id: determination
27+
run: |
28+
RELEASE_BRANCH_REGEX="refs/heads/[0-9]+.[0-9]+.x"
29+
# The `create` event trigger doesn't support `branches` filters, so it's necessary to use Bash instead.
30+
if [[
31+
"${{ github.event_name }}" != "create" ||
32+
"${{ github.ref }}" =~ $RELEASE_BRANCH_REGEX
33+
]]; then
34+
# Run the other jobs.
35+
RESULT="true"
36+
else
37+
# There is no need to run the other jobs.
38+
RESULT="false"
39+
fi
40+
41+
echo "result=$RESULT" >> $GITHUB_OUTPUT
42+
1943
spellcheck:
44+
needs: run-determination
45+
if: needs.run-determination.outputs.result == 'true'
2046
runs-on: ubuntu-latest
2147

2248
steps:

workflow-templates/check-action-metadata-task.yml

+26
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ env:
77

88
# See: https://docs.github.com/en/actions/reference/events-that-trigger-workflows
99
on:
10+
create:
1011
push:
1112
paths:
1213
- ".github/workflows/check-action-metadata-task.ya?ml"
@@ -28,7 +29,32 @@ on:
2829
repository_dispatch:
2930

3031
jobs:
32+
run-determination:
33+
runs-on: ubuntu-latest
34+
outputs:
35+
result: ${{ steps.determination.outputs.result }}
36+
steps:
37+
- name: Determine if the rest of the workflow should run
38+
id: determination
39+
run: |
40+
RELEASE_BRANCH_REGEX="refs/heads/[0-9]+.[0-9]+.x"
41+
# The `create` event trigger doesn't support `branches` filters, so it's necessary to use Bash instead.
42+
if [[
43+
"${{ github.event_name }}" != "create" ||
44+
"${{ github.ref }}" =~ $RELEASE_BRANCH_REGEX
45+
]]; then
46+
# Run the other jobs.
47+
RESULT="true"
48+
else
49+
# There is no need to run the other jobs.
50+
RESULT="false"
51+
fi
52+
53+
echo "result=$RESULT" >> $GITHUB_OUTPUT
54+
3155
validate:
56+
needs: run-determination
57+
if: needs.run-determination.outputs.result == 'true'
3258
runs-on: ubuntu-latest
3359

3460
steps:

workflow-templates/check-general-formatting-task.yml

+26
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ name: Check General Formatting
33

44
# See: https://docs.github.com/actions/using-workflows/events-that-trigger-workflows
55
on:
6+
create:
67
push:
78
pull_request:
89
schedule:
@@ -12,7 +13,32 @@ on:
1213
repository_dispatch:
1314

1415
jobs:
16+
run-determination:
17+
runs-on: ubuntu-latest
18+
outputs:
19+
result: ${{ steps.determination.outputs.result }}
20+
steps:
21+
- name: Determine if the rest of the workflow should run
22+
id: determination
23+
run: |
24+
RELEASE_BRANCH_REGEX="refs/heads/[0-9]+.[0-9]+.x"
25+
# The `create` event trigger doesn't support `branches` filters, so it's necessary to use Bash instead.
26+
if [[
27+
"${{ github.event_name }}" != "create" ||
28+
"${{ github.ref }}" =~ $RELEASE_BRANCH_REGEX
29+
]]; then
30+
# Run the other jobs.
31+
RESULT="true"
32+
else
33+
# There is no need to run the other jobs.
34+
RESULT="false"
35+
fi
36+
37+
echo "result=$RESULT" >> $GITHUB_OUTPUT
38+
1539
check:
40+
needs: run-determination
41+
if: needs.run-determination.outputs.result == 'true'
1642
runs-on: ubuntu-latest
1743

1844
steps:

workflow-templates/check-javascript-task.yml

+26
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ env:
77

88
# See: https://docs.github.com/actions/using-workflows/events-that-trigger-workflows
99
on:
10+
create:
1011
push:
1112
paths:
1213
- ".github/workflows/check-javascript-task.ya?ml"
@@ -32,7 +33,32 @@ permissions:
3233
contents: read
3334

3435
jobs:
36+
run-determination:
37+
runs-on: ubuntu-latest
38+
outputs:
39+
result: ${{ steps.determination.outputs.result }}
40+
steps:
41+
- name: Determine if the rest of the workflow should run
42+
id: determination
43+
run: |
44+
RELEASE_BRANCH_REGEX="refs/heads/[0-9]+.[0-9]+.x"
45+
# The `create` event trigger doesn't support `branches` filters, so it's necessary to use Bash instead.
46+
if [[
47+
"${{ github.event_name }}" != "create" ||
48+
"${{ github.ref }}" =~ $RELEASE_BRANCH_REGEX
49+
]]; then
50+
# Run the other jobs.
51+
RESULT="true"
52+
else
53+
# There is no need to run the other jobs.
54+
RESULT="false"
55+
fi
56+
57+
echo "result=$RESULT" >> $GITHUB_OUTPUT
58+
3559
check:
60+
needs: run-determination
61+
if: needs.run-determination.outputs.result == 'true'
3662
runs-on: ubuntu-latest
3763

3864
steps:

0 commit comments

Comments
 (0)