Skip to content

Commit 78f6151

Browse files
committed
Fix release branch regex for the project's release branch format
The project uses the standard GitHub Actions convention of providing a major version ref. A branch with the format `v<major>` is used for that purpose. These release branches may contain a subset of the history of the default branch. Although most often this would mirror the history on the `main` branch, in some cases it might be beneficial to cherry-pick the commits ready for release to the release branch, excluding other commits that are not yet ready for release. The status of the GitHub Actions workflows should be evaluated before making a release. However, this is not so simple as checking the status of the commit at the tip of the release branch. The reason is that, for the sake of efficiency, the workflows are configured to run only when the processes are relevant to the trigger event (e.g., no need to run unit tests for a change to the readme). In the case of the default branch, you can simply set the workflow runs filter to that branch and then check the result of the latest run of each workflow of interest. However, that was not possible to do with the release branch since it might be that the workflow was never run in that branch. The status of the latest run of the workflow in the default branch might not match the status for the release branch if the release branch does not contain the full history. For this reason, it will be helpful to trigger all relevant workflows on the creation of a release branch. This will ensure that each of those workflows will always have at least one run in the release branch. Subsequent commits pushed to the branch can run based on their usual trigger filters and the status of the latest run of each workflow in the branch will provide an accurate indication of the state of that branch. Branches are created for purposes other than releases, most notably feature branches to stage work for a pull request. Because the collection of workflows in a Tooling project are often very comprehensive, it would not be convenient or efficient to run them on the creation of every feature branch. Unfortunately, GitHub Actions does not support filters on the `create` event of branch creation like it does for the `push` and `pull_request` events. There is support for a `branches` filter of the `push` event, but that filter is an AND to the `paths` filter and this application requires an OR. For this reason, the workflows must be triggered by the creation of any branch. The unwanted job runs are prevented by adding a `run-determination` job with the branch filter handled by Bash commands. The other jobs of the workflow use this `run-determination` job as a dependency, only running when it indicates they should via a job output. Because this minimal `run-determination` job runs very quickly, it is roughly equivalent to the workflow having been skipped entirely for non-release branch creations. This approach has been in use for some time already in the versioned "Deploy Website" workflows. Previously the regular expression used to identify release branches used the `<major>.<minor>.x` format that is standard in non-action tooling projects, but wrong for this project.
1 parent b3ab95f commit 78f6151

13 files changed

+13
-13
lines changed

.github/workflows/check-action-metadata-task.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ jobs:
3737
- name: Determine if the rest of the workflow should run
3838
id: determination
3939
run: |
40-
RELEASE_BRANCH_REGEX="refs/heads/[0-9]+.[0-9]+.x"
40+
RELEASE_BRANCH_REGEX="^refs/heads/v[0-9]+$"
4141
# The `create` event trigger doesn't support `branches` filters, so it's necessary to use Bash instead.
4242
if [[
4343
"${{ github.event_name }}" != "create" ||

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ jobs:
2121
- name: Determine if the rest of the workflow should run
2222
id: determination
2323
run: |
24-
RELEASE_BRANCH_REGEX="refs/heads/[0-9]+.[0-9]+.x"
24+
RELEASE_BRANCH_REGEX="^refs/heads/v[0-9]+$"
2525
# The `create` event trigger doesn't support `branches` filters, so it's necessary to use Bash instead.
2626
if [[
2727
"${{ github.event_name }}" != "create" ||

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ jobs:
2121
- name: Determine if the rest of the workflow should run
2222
id: determination
2323
run: |
24-
RELEASE_BRANCH_REGEX="refs/heads/[0-9]+.[0-9]+.x"
24+
RELEASE_BRANCH_REGEX="^refs/heads/v[0-9]+$"
2525
# The `create` event trigger doesn't support `branches` filters, so it's necessary to use Bash instead.
2626
if [[
2727
"${{ github.event_name }}" != "create" ||

.github/workflows/check-license.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ jobs:
4141
- name: Determine if the rest of the workflow should run
4242
id: determination
4343
run: |
44-
RELEASE_BRANCH_REGEX="refs/heads/[0-9]+.[0-9]+.x"
44+
RELEASE_BRANCH_REGEX="^refs/heads/v[0-9]+$"
4545
# The `create` event trigger doesn't support `branches` filters, so it's necessary to use Bash instead.
4646
if [[
4747
"${{ github.event_name }}" != "create" ||

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ jobs:
4747
- name: Determine if the rest of the workflow should run
4848
id: determination
4949
run: |
50-
RELEASE_BRANCH_REGEX="refs/heads/[0-9]+.[0-9]+.x"
50+
RELEASE_BRANCH_REGEX="^refs/heads/v[0-9]+$"
5151
# The `create` event trigger doesn't support `branches` filters, so it's necessary to use Bash instead.
5252
if [[
5353
"${{ github.event_name }}" != "create" ||

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ jobs:
3838
- name: Determine if the rest of the workflow should run
3939
id: determination
4040
run: |
41-
RELEASE_BRANCH_REGEX="refs/heads/[0-9]+.[0-9]+.x"
41+
RELEASE_BRANCH_REGEX="^refs/heads/v[0-9]+$"
4242
# The `create` event trigger doesn't support `branches` filters, so it's necessary to use Bash instead.
4343
if [[
4444
"${{ github.event_name }}" != "create" ||

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ jobs:
215215
- name: Determine if the rest of the workflow should run
216216
id: determination
217217
run: |
218-
RELEASE_BRANCH_REGEX="refs/heads/[0-9]+.[0-9]+.x"
218+
RELEASE_BRANCH_REGEX="^refs/heads/v[0-9]+$"
219219
# The `create` event trigger doesn't support `branches` filters, so it's necessary to use Bash instead.
220220
if [[
221221
"${{ github.event_name }}" != "create" ||

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ jobs:
4141
- name: Determine if the rest of the workflow should run
4242
id: determination
4343
run: |
44-
RELEASE_BRANCH_REGEX="refs/heads/[0-9]+.[0-9]+.x"
44+
RELEASE_BRANCH_REGEX="^refs/heads/v[0-9]+$"
4545
# The `create` event trigger doesn't support `branches` filters, so it's necessary to use Bash instead.
4646
if [[
4747
"${{ github.event_name }}" != "create" ||

.github/workflows/check-taskfiles.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ jobs:
3535
- name: Determine if the rest of the workflow should run
3636
id: determination
3737
run: |
38-
RELEASE_BRANCH_REGEX="refs/heads/[0-9]+.[0-9]+.x"
38+
RELEASE_BRANCH_REGEX="^refs/heads/v[0-9]+$"
3939
# The `create` event trigger doesn't support `branches` filters, so it's necessary to use Bash instead.
4040
if [[
4141
"${{ github.event_name }}" != "create" ||

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ jobs:
3535
- name: Determine if the rest of the workflow should run
3636
id: determination
3737
run: |
38-
RELEASE_BRANCH_REGEX="refs/heads/[0-9]+.[0-9]+.x"
38+
RELEASE_BRANCH_REGEX="^refs/heads/v[0-9]+$"
3939
# The `create` event trigger doesn't support `branches` filters, so it's necessary to use Bash instead.
4040
if [[
4141
"${{ github.event_name }}" != "create" ||

0 commit comments

Comments
 (0)