77
88# See: https://docs.github.com/en/actions/reference/events-that-trigger-workflows
99on :
10+ create :
1011 push :
1112 paths :
1213 - " .github/workflows/check-go-task.ya?ml"
2526 repository_dispatch :
2627
2728jobs :
29+ run-determination :
30+ runs-on : ubuntu-latest
31+ outputs :
32+ result : ${{ steps.determination.outputs.result }}
33+ steps :
34+ - name : Determine if the rest of the workflow should run
35+ id : determination
36+ run : |
37+ RELEASE_BRANCH_REGEX="refs/heads/[0-9]+.[0-9]+.x"
38+ # 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 \
42+ ]]; then
43+ # Run the other jobs.
44+ RESULT="true"
45+ else
46+ # There is no need to run the other jobs.
47+ RESULT="false"
48+ fi
49+
50+ echo "::set-output name=result::$RESULT"
51+
2852 check-errors :
53+ needs : run-determination
54+ if : needs.run-determination.outputs.result == 'true'
2955 runs-on : ubuntu-latest
3056
3157 steps :
4773 run : task go:vet
4874
4975 check-outdated :
76+ needs : run-determination
77+ if : needs.run-determination.outputs.result == 'true'
5078 runs-on : ubuntu-latest
5179
5280 steps :
7199 run : git diff --color --exit-code
72100
73101 check-style :
102+ needs : run-determination
103+ if : needs.run-determination.outputs.result == 'true'
74104 runs-on : ubuntu-latest
75105
76106 steps :
95125 run : task --silent go:lint
96126
97127 check-formatting :
128+ needs : run-determination
129+ if : needs.run-determination.outputs.result == 'true'
98130 runs-on : ubuntu-latest
99131
100132 steps :
@@ -120,6 +152,8 @@ jobs:
120152
121153 check-config :
122154 name : check-config (${{ matrix.module.path }})
155+ needs : run-determination
156+ if : needs.run-determination.outputs.result == 'true'
123157 runs-on : ubuntu-latest
124158
125159 strategy :
0 commit comments