Skip to content

Commit 806b624

Browse files
Merge pull request #56 from MatteoPologruto/update-check-taskfiles
Update check-taskfiles workflow
2 parents d274e93 + d52b54d commit 806b624

File tree

4 files changed

+589
-16
lines changed

4 files changed

+589
-16
lines changed

.github/workflows/check-taskfiles.yml

Lines changed: 53 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,25 @@
11
# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/check-taskfiles.md
22
name: Check Taskfiles
33

4-
# See: https://docs.github.com/en/actions/reference/events-that-trigger-workflows
4+
env:
5+
# See: https://github.com/actions/setup-node/#readme
6+
NODE_VERSION: 16.x
7+
8+
# See: https://docs.github.com/actions/using-workflows/events-that-trigger-workflows
59
on:
10+
create:
611
push:
712
paths:
813
- ".github/workflows/check-taskfiles.ya?ml"
14+
- "package.json"
15+
- "package-lock.json"
916
- "**/Taskfile.ya?ml"
1017
- "**/DistTasks.ya?ml"
1118
pull_request:
1219
paths:
1320
- ".github/workflows/check-taskfiles.ya?ml"
21+
- "package.json"
22+
- "package-lock.json"
1423
- "**/Taskfile.ya?ml"
1524
- "**/DistTasks.ya?ml"
1625
schedule:
@@ -20,44 +29,72 @@ on:
2029
repository_dispatch:
2130

2231
jobs:
32+
run-determination:
33+
runs-on: ubuntu-latest
34+
outputs:
35+
result: ${{ steps.determination.outputs.result }}
36+
steps:
37+
- name: Determine if the rest of the workflow should run
38+
id: determination
39+
run: |
40+
RELEASE_BRANCH_REGEX="refs/heads/[0-9]+.[0-9]+.x"
41+
# The `create` event trigger doesn't support `branches` filters, so it's necessary to use Bash instead.
42+
if [[
43+
"${{ github.event_name }}" != "create" ||
44+
"${{ github.ref }}" =~ $RELEASE_BRANCH_REGEX
45+
]]; then
46+
# Run the other jobs.
47+
RESULT="true"
48+
else
49+
# There is no need to run the other jobs.
50+
RESULT="false"
51+
fi
52+
53+
echo "result=$RESULT" >> $GITHUB_OUTPUT
54+
2355
validate:
2456
name: Validate ${{ matrix.file }}
57+
needs: run-determination
58+
if: needs.run-determination.outputs.result == 'true'
2559
runs-on: ubuntu-latest
2660

2761
strategy:
2862
fail-fast: false
2963

3064
matrix:
3165
file:
32-
# TODO: add paths to any additional Taskfiles here
3366
- ./**/Taskfile.yml
34-
- ./DistTasks.yml
67+
- ./**/DistTasks.yml
3568

3669
steps:
3770
- name: Checkout repository
3871
uses: actions/checkout@v3
3972

73+
- name: Setup Node.js
74+
uses: actions/setup-node@v3
75+
with:
76+
node-version: ${{ env.NODE_VERSION }}
77+
4078
- name: Download JSON schema for Taskfiles
4179
id: download-schema
4280
uses: carlosperate/download-file-action@v2
4381
with:
44-
# See: https://github.com/SchemaStore/schemastore/blob/master/src/schemas/json/taskfile.json
45-
file-url: https://json.schemastore.org/taskfile.json
82+
# Source: https://github.com/SchemaStore/schemastore/blob/master/src/schemas/json/taskfile.json
83+
file-url: https://taskfile.dev/schema.json
4684
location: ${{ runner.temp }}/taskfile-schema
4785

4886
- name: Install JSON schema validator
49-
run: |
50-
sudo npm install \
51-
--global \
52-
ajv-cli \
53-
ajv-formats
87+
run: npm install
5488

5589
- name: Validate ${{ matrix.file }}
5690
run: |
5791
# See: https://github.com/ajv-validator/ajv-cli#readme
58-
ajv validate \
59-
--all-errors \
60-
--strict=false \
61-
-c ajv-formats \
62-
-s "${{ steps.download-schema.outputs.file-path }}" \
63-
-d "${{ matrix.file }}"
92+
npx \
93+
--package=ajv-cli \
94+
--package=ajv-formats \
95+
ajv validate \
96+
--all-errors \
97+
--strict=false \
98+
-c ajv-formats \
99+
-s "${{ steps.download-schema.outputs.file-path }}" \
100+
-d "${{ matrix.file }}"

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,5 @@ __pycache__/
1212
*.sublime-workspace
1313

1414
/dist
15+
16+
/node_modules/

0 commit comments

Comments
 (0)