|
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.17" |
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: |
|
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 |
|
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: |
|
0 commit comments