Skip to content

Commit c28b1f8

Browse files
authored
Merge pull request #221 from per1234/more-release-branch-triggers
Run relevant workflows on release branch creation
2 parents 6d108f7 + 22504dc commit c28b1f8

32 files changed

+641
-43
lines changed

Diff for: .github/workflows/check-license.yml

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

1010
# See: https://docs.github.com/actions/using-workflows/events-that-trigger-workflows
1111
on:
12+
create:
1213
push:
1314
paths:
1415
- ".github/workflows/check-license.ya?ml"
@@ -30,7 +31,32 @@ on:
3031
repository_dispatch:
3132

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

3662
steps:

Diff for: .github/workflows/check-markdown-task.yml

+28
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ name: Check Markdown
33

44
# See: https://docs.github.com/actions/using-workflows/events-that-trigger-workflows
55
on:
6+
create:
67
push:
78
paths:
89
- ".github/workflows/check-markdown-task.ya?ml"
@@ -30,7 +31,32 @@ on:
3031
repository_dispatch:
3132

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

3662
steps:
@@ -50,6 +76,8 @@ jobs:
5076
run: task markdown:lint
5177

5278
links:
79+
needs: run-determination
80+
if: needs.run-determination.outputs.result == 'true'
5381
runs-on: ubuntu-latest
5482

5583
steps:

Diff for: .github/workflows/check-python-task.yml

+28
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-python-task.ya?ml"
@@ -31,7 +32,32 @@ on:
3132
repository_dispatch:
3233

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

3763
steps:
@@ -59,6 +85,8 @@ jobs:
5985
run: task python:lint
6086

6187
formatting:
88+
needs: run-determination
89+
if: needs.run-determination.outputs.result == 'true'
6290
runs-on: ubuntu-latest
6391

6492
steps:

Diff for: .github/workflows/check-shell-task.yml

+30
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ name: Check Shell Scripts
33

44
# See: https://docs.github.com/actions/using-workflows/events-that-trigger-workflows
55
on:
6+
create:
67
push:
78
paths:
89
- ".github/workflows/check-shell-task.ya?ml"
@@ -24,8 +25,33 @@ on:
2425
repository_dispatch:
2526

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

3157
env:
@@ -88,6 +114,8 @@ jobs:
88114
run: task --silent shell:check SHELLCHECK_FORMAT=${{ matrix.configuration.format }}
89115

90116
formatting:
117+
needs: run-determination
118+
if: needs.run-determination.outputs.result == 'true'
91119
runs-on: ubuntu-latest
92120

93121
steps:
@@ -131,6 +159,8 @@ jobs:
131159
run: git diff --color --exit-code
132160

133161
executable:
162+
needs: run-determination
163+
if: needs.run-determination.outputs.result == 'true'
134164
runs-on: ubuntu-latest
135165

136166
steps:

Diff for: .github/workflows/check-yaml-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
- ".yamllint*"
@@ -43,8 +44,33 @@ on:
4344
repository_dispatch:
4445

4546
jobs:
47+
run-determination:
48+
runs-on: ubuntu-latest
49+
outputs:
50+
result: ${{ steps.determination.outputs.result }}
51+
steps:
52+
- name: Determine if the rest of the workflow should run
53+
id: determination
54+
run: |
55+
RELEASE_BRANCH_REGEX="refs/heads/[0-9]+.[0-9]+.x"
56+
# The `create` event trigger doesn't support `branches` filters, so it's necessary to use Bash instead.
57+
if [[
58+
"${{ github.event_name }}" != "create" ||
59+
"${{ github.ref }}" =~ $RELEASE_BRANCH_REGEX
60+
]]; then
61+
# Run the other jobs.
62+
RESULT="true"
63+
else
64+
# There is no need to run the other jobs.
65+
RESULT="false"
66+
fi
67+
68+
echo "::set-output name=result::$RESULT"
69+
4670
check:
4771
name: ${{ matrix.configuration.name }}
72+
needs: run-determination
73+
if: needs.run-determination.outputs.result == 'true'
4874
runs-on: ubuntu-latest
4975

5076
strategy:

Diff for: .github/workflows/test-python-poetry-task.yml

+3-3
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,9 @@ jobs:
3838
run: |
3939
RELEASE_BRANCH_REGEX="refs/heads/[0-9]+.[0-9]+.x"
4040
# The `create` event trigger doesn't support `branches` filters, so it's necessary to use Bash instead.
41-
if [[ \
42-
"${{ github.event_name }}" != "create" || \
43-
"${{ github.ref }}" =~ $RELEASE_BRANCH_REGEX \
41+
if [[
42+
"${{ github.event_name }}" != "create" ||
43+
"${{ github.ref }}" =~ $RELEASE_BRANCH_REGEX
4444
]]; then
4545
# Run the other jobs.
4646
RESULT="true"

Diff for: workflow-templates/check-certificates.yml

+43-5
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ name: Check Certificates
33

44
# See: https://docs.github.com/actions/using-workflows/events-that-trigger-workflows
55
on:
6+
create:
67
push:
78
paths:
89
- ".github/workflows/check-certificates.ya?ml"
@@ -20,13 +21,50 @@ env:
2021
EXPIRATION_WARNING_PERIOD: 30
2122

2223
jobs:
24+
run-determination:
25+
runs-on: ubuntu-latest
26+
outputs:
27+
result: ${{ steps.determination.outputs.result }}
28+
steps:
29+
- name: Determine if the rest of the workflow should run
30+
id: determination
31+
run: |
32+
RELEASE_BRANCH_REGEX="refs/heads/[0-9]+.[0-9]+.x"
33+
# TODO: Update repository name.
34+
REPO_SLUG="REPO_OWNER/REPO_NAME"
35+
if [[
36+
(
37+
# Only run on branch creation when it is a release branch.
38+
# The `create` event trigger doesn't support `branches` filters, so it's necessary to use Bash instead.
39+
"${{ github.event_name }}" != "create" ||
40+
"${{ github.ref }}" =~ $RELEASE_BRANCH_REGEX
41+
) &&
42+
(
43+
# Only run when the workflow will have access to the certificate secrets.
44+
# This could be done via a GitHub Actions workflow conditional, but makes more sense to do it here as well.
45+
(
46+
"${{ github.event_name }}" != "pull_request" &&
47+
"${{ github.repository }}" == "$REPO_SLUG"
48+
) ||
49+
(
50+
"${{ github.event_name }}" == "pull_request" &&
51+
"${{ github.event.pull_request.head.repo.full_name }}" == "$REPO_SLUG"
52+
)
53+
)
54+
]]; then
55+
# Run the other jobs.
56+
RESULT="true"
57+
else
58+
# There is no need to run the other jobs.
59+
RESULT="false"
60+
fi
61+
62+
echo "::set-output name=result::$RESULT"
63+
2364
check-certificates:
2465
name: ${{ matrix.certificate.identifier }}
25-
# Only run when the workflow will have access to the certificate secrets.
26-
# TODO: Update repository name.
27-
if: >
28-
(github.event_name != 'pull_request' && github.repository == 'REPO_OWNER/REPO_NAME') ||
29-
(github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == 'REPO_OWNER/REPO_NAME')
66+
needs: run-determination
67+
if: needs.run-determination.outputs.result == 'true'
3068
runs-on: ubuntu-latest
3169
strategy:
3270
fail-fast: false

Diff for: workflow-templates/check-go-dependencies-task.yml

+28
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-go-dependencies-task.ya?ml"
@@ -31,7 +32,32 @@ on:
3132
repository_dispatch:
3233

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

3763
steps:
@@ -80,6 +106,8 @@ jobs:
80106
path: .licenses/
81107

82108
check-deps:
109+
needs: run-determination
110+
if: needs.run-determination.outputs.result == 'true'
83111
runs-on: ubuntu-latest
84112

85113
steps:

Diff for: workflow-templates/check-go-task.yml

+3-3
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,9 @@ jobs:
3636
run: |
3737
RELEASE_BRANCH_REGEX="refs/heads/[0-9]+.[0-9]+.x"
3838
# The `create` event trigger doesn't support `branches` filters, so it's necessary to use Bash instead.
39-
if [[ \
40-
"${{ github.event_name }}" != "create" || \
41-
"${{ github.ref }}" =~ $RELEASE_BRANCH_REGEX \
39+
if [[
40+
"${{ github.event_name }}" != "create" ||
41+
"${{ github.ref }}" =~ $RELEASE_BRANCH_REGEX
4242
]]; then
4343
# Run the other jobs.
4444
RESULT="true"

0 commit comments

Comments
 (0)