2
2
name : Check Go Dependencies
3
3
4
4
env :
5
- # See: https://github.com/actions/setup-go/tree/v2 #readme
5
+ # See: https://github.com/actions/setup-go/tree/v3 #readme
6
6
GO_VERSION : " 1.13"
7
7
8
- # See: https://docs.github.com/en/ actions/reference /events-that-trigger-workflows
8
+ # See: https://docs.github.com/actions/using-workflows /events-that-trigger-workflows
9
9
on :
10
+ create :
10
11
push :
11
12
paths :
12
13
- " .github/workflows/check-go-dependencies-task.ya?ml"
27
28
- " **/.gitmodules"
28
29
- " **/go.mod"
29
30
- " **/go.sum"
31
+ schedule :
32
+ # Run periodically to catch breakage caused by external changes.
33
+ - cron : " 0 8 * * WED"
30
34
workflow_dispatch :
31
35
repository_dispatch :
32
36
33
37
jobs :
38
+ run-determination :
39
+ runs-on : ubuntu-latest
40
+ outputs :
41
+ result : ${{ steps.determination.outputs.result }}
42
+ steps :
43
+ - name : Determine if the rest of the workflow should run
44
+ id : determination
45
+ run : |
46
+ RELEASE_BRANCH_REGEX="refs/heads/[0-9]+.[0-9]+.x"
47
+ # The `create` event trigger doesn't support `branches` filters, so it's necessary to use Bash instead.
48
+ if [[
49
+ "${{ github.event_name }}" != "create" ||
50
+ "${{ github.ref }}" =~ $RELEASE_BRANCH_REGEX
51
+ ]]; then
52
+ # Run the other jobs.
53
+ RESULT="true"
54
+ else
55
+ # There is no need to run the other jobs.
56
+ RESULT="false"
57
+ fi
58
+
59
+ echo "::set-output name=result::$RESULT"
60
+
34
61
check-cache :
62
+ needs : run-determination
63
+ if : needs.run-determination.outputs.result == 'true'
35
64
runs-on : ubuntu-latest
36
65
37
66
steps :
38
67
- name : Checkout repository
39
- uses : actions/checkout@v2
68
+ uses : actions/checkout@v3
40
69
with :
41
70
submodules : recursive
42
71
47
76
version : 3.x
48
77
49
78
- name : Install Go
50
- uses : actions/setup-go@v2
79
+ uses : actions/setup-go@v3
51
80
with :
52
81
go-version : ${{ env.GO_VERSION }}
53
82
63
92
- name : Check for outdated cache
64
93
id : diff
65
94
run : |
66
- git add --intent-to-add .
67
- if ! git diff --color --exit-code; then
95
+ git add .
96
+ if ! git diff --cached -- color --exit-code; then
68
97
echo
69
98
echo "::error::Dependency license metadata out of sync. See: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/check-go-dependencies-task.md#metadata-cache"
70
99
exit 1
@@ -73,18 +102,20 @@ jobs:
73
102
# Some might find it convenient to have CI generate the cache rather than setting up for it locally
74
103
- name : Upload cache to workflow artifact
75
104
if : failure() && steps.diff.outcome == 'failure'
76
- uses : actions/upload-artifact@v2
105
+ uses : actions/upload-artifact@v3
77
106
with :
78
107
if-no-files-found : error
79
108
name : dep-licenses-cache
80
109
path : .licenses/
81
110
82
111
check-deps :
112
+ needs : run-determination
113
+ if : needs.run-determination.outputs.result == 'true'
83
114
runs-on : ubuntu-latest
84
115
85
116
steps :
86
117
- name : Checkout repository
87
- uses : actions/checkout@v2
118
+ uses : actions/checkout@v3
88
119
with :
89
120
submodules : recursive
90
121
95
126
version : 3.x
96
127
97
128
- name : Install Go
98
- uses : actions/setup-go@v2
129
+ uses : actions/setup-go@v3
99
130
with :
100
131
go-version : ${{ env.GO_VERSION }}
101
132
0 commit comments