Skip to content

Commit 18f55f6

Browse files
authored
Merge pull request #377 from per1234/sync-check-deps
Sync "Check Go Dependencies" workflow with upstream
2 parents 45d65c0 + fde91a5 commit 18f55f6

File tree

1 file changed

+35
-4
lines changed

1 file changed

+35
-4
lines changed

.github/workflows/check-go-dependencies-task.yml

+35-4
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,12 @@
22
name: Check Go Dependencies
33

44
env:
5-
# See: https://github.com/actions/setup-go/tree/v2#readme
5+
# See: https://github.com/actions/setup-go/tree/v3#readme
66
GO_VERSION: "1.17"
77

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
99
on:
10+
create:
1011
push:
1112
paths:
1213
- ".github/workflows/check-go-dependencies-task.ya?ml"
@@ -27,11 +28,39 @@ on:
2728
- "**/.gitmodules"
2829
- "**/go.mod"
2930
- "**/go.sum"
31+
schedule:
32+
# Run periodically to catch breakage caused by external changes.
33+
- cron: "0 8 * * WED"
3034
workflow_dispatch:
3135
repository_dispatch:
3236

3337
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+
3461
check-cache:
62+
needs: run-determination
63+
if: needs.run-determination.outputs.result == 'true'
3564
runs-on: ubuntu-latest
3665

3766
steps:
@@ -63,8 +92,8 @@ jobs:
6392
- name: Check for outdated cache
6493
id: diff
6594
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
6897
echo
6998
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"
7099
exit 1
@@ -80,6 +109,8 @@ jobs:
80109
path: .licenses/
81110

82111
check-deps:
112+
needs: run-determination
113+
if: needs.run-determination.outputs.result == 'true'
83114
runs-on: ubuntu-latest
84115

85116
steps:

0 commit comments

Comments
 (0)