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/using-workflows/events-that-trigger-workflows
5 on:
6 create:
7 push:
8 paths:
9 - ".github/workflows/check-taskfiles.ya?ml"
10 - "package.json"
11 - "package-lock.json"
12 - "**/Taskfile.ya?ml"
13 pull_request:
14 paths:
15 - ".github/workflows/check-taskfiles.ya?ml"
16 - "package.json"
17 - "package-lock.json"
18 - "**/Taskfile.ya?ml"
19 schedule:
20 # Run every Tuesday at 8 AM UTC to catch breakage resulting from changes to the JSON schema.
21 - cron: "0 8 * * TUE"
22 workflow_dispatch:
23 repository_dispatch:
24
25 jobs:
26 run-determination:
27 runs-on: ubuntu-latest
28 permissions: {}
29 outputs:
30 result: ${{ steps.determination.outputs.result }}
31 steps:
32 - name: Determine if the rest of the workflow should run
33 id: determination
34 run: |
35 RELEASE_BRANCH_REGEX="refs/heads/[0-9]+.[0-9]+.x"
36 # The `create` event trigger doesn't support `branches` filters, so it's necessary to use Bash instead.
37 if [[
38 "${{ github.event_name }}" != "create" ||
39 "${{ github.ref }}" =~ $RELEASE_BRANCH_REGEX
40 ]]; then
41 # Run the other jobs.
42 RESULT="true"
43 else
44 # There is no need to run the other jobs.
45 RESULT="false"
46 fi
47
48 echo "result=$RESULT" >> $GITHUB_OUTPUT
49
50 validate:
51 name: Validate ${{ matrix.file }}
52 needs: run-determination
53 if: needs.run-determination.outputs.result == 'true'
54 runs-on: ubuntu-latest
55 permissions:
56 contents: read
57
58 strategy:
59 fail-fast: false
60
61 matrix:
62 file:
63 - ./**/Taskfile.yml
64
65 steps:
66 - name: Checkout repository
67 uses: actions/checkout@v7
68
69 - name: Setup Node.js
70 uses: actions/setup-node@v7
71 with:
72 node-version-file: package.json
73
74 - name: Download JSON schema for Taskfiles
75 id: download-schema
76 uses: carlosperate/download-file-action@v2
77 with:
78 # Source: https://github.com/SchemaStore/schemastore/blob/master/src/schemas/json/taskfile.json
79 file-url: https://taskfile.dev/schema.json
80 location: ${{ runner.temp }}/taskfile-schema
81
82 - name: Install JSON schema validator
83 run: npm install
84
85 - name: Validate ${{ matrix.file }}
86 run: |
87 # See: https://github.com/ajv-validator/ajv-cli#readme
88 npx \
89 --package=ajv-cli \
90 --package=ajv-formats \
91 ajv validate \
92 --all-errors \
93 --strict=false \
94 -c ajv-formats \
95 -s "${{ steps.download-schema.outputs.file-path }}" \
96 -d "${{ matrix.file }}"