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
2
2
name : Sync Labels
3
3
4
4
# See: https://docs.github.com/actions/writing-workflows/choosing-when-your-workflow-runs/events-that-trigger-workflows
5
5
on :
6
6
push :
7
7
paths :
8
- - " .github/workflows/sync-labels.ya?ml"
8
+ - " .github/workflows/sync-labels-npm .ya?ml"
9
9
- " .github/label-configuration-files/*.ya?ml"
10
+ - " .npmrc"
11
+ - " package.json"
12
+ - " package-lock.json"
10
13
pull_request :
11
14
paths :
12
- - " .github/workflows/sync-labels.ya?ml"
15
+ - " .github/workflows/sync-labels-npm .ya?ml"
13
16
- " .github/label-configuration-files/*.ya?ml"
17
+ - " .npmrc"
18
+ - " package.json"
19
+ - " package-lock.json"
14
20
schedule :
15
21
# Run daily at 8 AM UTC to sync with changes to shared label configurations.
16
22
- cron : " 0 8 * * *"
31
37
- name : Checkout repository
32
38
uses : actions/checkout@v4
33
39
40
+ - name : Setup Node.js
41
+ uses : actions/setup-node@v4
42
+ with :
43
+ node-version-file : package.json
44
+
34
45
- name : Download JSON schema for labels configuration file
35
46
id : download-schema
36
47
uses : carlosperate/download-file-action@v2
@@ -39,20 +50,19 @@ jobs:
39
50
location : ${{ runner.temp }}/label-configuration-schema
40
51
41
52
- name : Install JSON schema validator
42
- run : |
43
- sudo npm install \
44
- --global \
45
- ajv-cli \
46
- ajv-formats
53
+ run : npm install
47
54
48
55
- name : Validate local labels configuration
49
56
run : |
50
57
# 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}"
56
66
57
67
download :
58
68
needs : check
@@ -126,21 +136,27 @@ jobs:
126
136
with :
127
137
name : ${{ env.CONFIGURATIONS_ARTIFACT_PREFIX }}*
128
138
139
+ - name : Setup Node.js
140
+ uses : actions/setup-node@v4
141
+ with :
142
+ node-version-file : package.json
143
+
129
144
- name : Merge label configuration files
130
145
run : |
131
146
# Merge all configuration files
132
147
shopt -s extglob
133
148
cat "${{ env.CONFIGURATIONS_FOLDER }}"/*.@(yml|yaml) > "${{ env.MERGED_CONFIGURATION_PATH }}"
134
149
135
150
- name : Install github-label-sync
136
- run : sudo npm install --global github-label-sync
151
+ run : npm install
137
152
138
153
- name : Sync labels
139
154
env :
140
155
GITHUB_ACCESS_TOKEN : ${{ secrets.GITHUB_TOKEN }}
141
156
run : |
142
157
# 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