1- # Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/sync-labels.md
1+ # Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/sync-labels-npm .md
22name : Sync Labels
33
44# See: https://docs.github.com/actions/writing-workflows/choosing-when-your-workflow-runs/events-that-trigger-workflows
55on :
66 push :
77 paths :
8- - " .github/workflows/sync-labels.ya?ml"
8+ - " .github/workflows/sync-labels-npm .ya?ml"
99 - " .github/label-configuration-files/*.ya?ml"
10+ - " .npmrc"
11+ - " package.json"
12+ - " package-lock.json"
1013 pull_request :
1114 paths :
12- - " .github/workflows/sync-labels.ya?ml"
15+ - " .github/workflows/sync-labels-npm .ya?ml"
1316 - " .github/label-configuration-files/*.ya?ml"
17+ - " .npmrc"
18+ - " package.json"
19+ - " package-lock.json"
1420 schedule :
1521 # Run daily at 8 AM UTC to sync with changes to shared label configurations.
1622 - cron : " 0 8 * * *"
3137 - name : Checkout repository
3238 uses : actions/checkout@v4
3339
40+ - name : Setup Node.js
41+ uses : actions/setup-node@v4
42+ with :
43+ node-version-file : package.json
44+
3445 - name : Download JSON schema for labels configuration file
3546 id : download-schema
3647 uses : carlosperate/download-file-action@v2
@@ -39,20 +50,19 @@ jobs:
3950 location : ${{ runner.temp }}/label-configuration-schema
4051
4152 - name : Install JSON schema validator
42- run : |
43- sudo npm install \
44- --global \
45- ajv-cli \
46- ajv-formats
53+ run : npm install
4754
4855 - name : Validate local labels configuration
4956 run : |
5057 # See: https://github.com/ajv-validator/ajv-cli#readme
51- ajv validate \
52- --all-errors \
53- -c ajv-formats \
54- -s "${{ steps.download-schema.outputs.file-path }}" \
55- -d "${{ env.CONFIGURATIONS_FOLDER }}/*.{yml,yaml}"
58+ npx \
59+ --package=ajv-cli \
60+ --package=ajv-formats \
61+ ajv validate \
62+ --all-errors \
63+ -c ajv-formats \
64+ -s "${{ steps.download-schema.outputs.file-path }}" \
65+ -d "${{ env.CONFIGURATIONS_FOLDER }}/*.{yml,yaml}"
5666
5767 download :
5868 needs : check
@@ -126,21 +136,27 @@ jobs:
126136 with :
127137 name : ${{ env.CONFIGURATIONS_ARTIFACT_PREFIX }}*
128138
139+ - name : Setup Node.js
140+ uses : actions/setup-node@v4
141+ with :
142+ node-version-file : package.json
143+
129144 - name : Merge label configuration files
130145 run : |
131146 # Merge all configuration files
132147 shopt -s extglob
133148 cat "${{ env.CONFIGURATIONS_FOLDER }}"/*.@(yml|yaml) > "${{ env.MERGED_CONFIGURATION_PATH }}"
134149
135150 - name : Install github-label-sync
136- run : sudo npm install --global github-label-sync
151+ run : npm install
137152
138153 - name : Sync labels
139154 env :
140155 GITHUB_ACCESS_TOKEN : ${{ secrets.GITHUB_TOKEN }}
141156 run : |
142157 # See: https://github.com/Financial-Times/github-label-sync
143- github-label-sync \
144- --labels "${{ env.MERGED_CONFIGURATION_PATH }}" \
145- ${{ steps.dry-run.outputs.flag }} \
146- ${{ github.repository }}
158+ npx \
159+ github-label-sync \
160+ --labels "${{ env.MERGED_CONFIGURATION_PATH }}" \
161+ ${{ steps.dry-run.outputs.flag }} \
162+ ${{ github.repository }}
0 commit comments