Debian Codegraph @

.github/workflows/check-taskfiles.yml

raw
1 # Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/check-taskfiles.md
2 name: Check Taskfiles
3
4 # See: https://docs.github.com/actions/reference/workflows-and-actions/events-that-trigger-workflows
5 on:
6 create:
7 push:
8 paths:
9 - ".github/workflows/check-taskfiles.ya?ml"
10 - ".npmrc"
11 - "package.json"
12 - "package-lock.json"
13 - "**/Taskfile.ya?ml"
14 pull_request:
15 paths:
16 - ".github/workflows/check-taskfiles.ya?ml"
17 - ".npmrc"
18 - "package.json"
19 - "package-lock.json"
20 - "**/Taskfile.ya?ml"
21 schedule:
22 # Run every Tuesday at 8 AM UTC to catch breakage resulting from changes to the JSON schema.
23 - cron: "0 8 * * TUE"
24 workflow_dispatch:
25 repository_dispatch:
26
27 jobs:
28 run-determination:
29 runs-on: ubuntu-latest
30 permissions: {}
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 "result=$RESULT" >>$GITHUB_OUTPUT
51
52 validate:
53 name: Validate ${{ matrix.file }}
54 needs: run-determination
55 if: needs.run-determination.outputs.result == 'true'
56 runs-on: ubuntu-latest
57 permissions:
58 contents: read
59
60 strategy:
61 fail-fast: false
62
63 matrix:
64 file:
65 # TODO: add paths to any additional Taskfiles here
66 - ./**/Taskfile.yml
67
68 steps:
69 - name: Checkout repository
70 uses: actions/checkout@v7
71
72 - name: Setup Node.js
73 uses: actions/setup-node@v7
74 with:
75 node-version-file: package.json
76
77 - name: Download JSON schema for Taskfiles
78 id: download-schema
79 uses: carlosperate/download-file-action@v2
80 with:
81 # Source: https://github.com/SchemaStore/schemastore/blob/master/src/schemas/json/taskfile.json
82 file-url: https://taskfile.dev/schema.json
83 location: ${{ runner.temp }}/taskfile-schema
84
85 - name: Install JSON schema validator
86 run: npm install
87
88 - name: Validate ${{ matrix.file }}
89 run: |
90 # See: https://github.com/ajv-validator/ajv-cli#readme
91 npx \
92 --package=ajv-cli \
93 --package=ajv-formats \
94 ajv validate \
95 --all-errors \
96 --strict=false \
97 -c ajv-formats \
98 -s "${{ steps.download-schema.outputs.file-path }}" \
99 -d "${{ matrix.file }}"