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
+ env :
5
+ # See: https://github.com/actions/setup-node/#readme
6
+ NODE_VERSION : 16.x
7
+ CONFIGURATIONS_FOLDER : .github/label-configuration-files
8
+ CONFIGURATIONS_ARTIFACT : label-configuration-files
9
+
4
10
# See: https://docs.github.com/actions/using-workflows/events-that-trigger-workflows
5
11
on :
6
12
push :
7
13
paths :
8
- - " .github/workflows/sync-labels.ya?ml"
14
+ - " .github/workflows/sync-labels-npm .ya?ml"
9
15
- " .github/label-configuration-files/*.ya?ml"
16
+ - " package.json"
17
+ - " package-lock.json"
10
18
pull_request :
11
19
paths :
12
- - " .github/workflows/sync-labels.ya?ml"
20
+ - " .github/workflows/sync-labels-npm .ya?ml"
13
21
- " .github/label-configuration-files/*.ya?ml"
22
+ - " package.json"
23
+ - " package-lock.json"
14
24
schedule :
15
25
# Run daily at 8 AM UTC to sync with changes to shared label configurations.
16
26
- cron : " 0 8 * * *"
17
27
workflow_dispatch :
18
28
repository_dispatch :
19
29
20
- env :
21
- CONFIGURATIONS_FOLDER : .github/label-configuration-files
22
- CONFIGURATIONS_ARTIFACT : label-configuration-files
23
-
24
30
jobs :
25
31
check :
26
32
runs-on : ubuntu-latest
29
35
- name : Checkout repository
30
36
uses : actions/checkout@v3
31
37
38
+ - name : Setup Node.js
39
+ uses : actions/setup-node@v3
40
+ with :
41
+ node-version : ${{ env.NODE_VERSION }}
42
+
32
43
- name : Download JSON schema for labels configuration file
33
44
id : download-schema
34
45
uses : carlosperate/download-file-action@v1
@@ -37,20 +48,19 @@ jobs:
37
48
location : ${{ runner.temp }}/label-configuration-schema
38
49
39
50
- name : Install JSON schema validator
40
- run : |
41
- sudo npm install \
42
- --global \
43
- ajv-cli \
44
- ajv-formats
51
+ run : npm install
45
52
46
53
- name : Validate local labels configuration
47
54
run : |
48
55
# See: https://github.com/ajv-validator/ajv-cli#readme
49
- ajv validate \
50
- --all-errors \
51
- -c ajv-formats \
52
- -s "${{ steps.download-schema.outputs.file-path }}" \
53
- -d "${{ env.CONFIGURATIONS_FOLDER }}/*.{yml,yaml}"
56
+ npx \
57
+ --package=ajv-cli \
58
+ --package=ajv-formats \
59
+ ajv validate \
60
+ --all-errors \
61
+ -c ajv-formats \
62
+ -s "${{ steps.download-schema.outputs.file-path }}" \
63
+ -d "${{ env.CONFIGURATIONS_FOLDER }}/*.{yml,yaml}"
54
64
55
65
download :
56
66
needs : check
@@ -118,21 +128,27 @@ jobs:
118
128
with :
119
129
name : ${{ env.CONFIGURATIONS_ARTIFACT }}
120
130
131
+ - name : Setup Node.js
132
+ uses : actions/setup-node@v3
133
+ with :
134
+ node-version : ${{ env.NODE_VERSION }}
135
+
121
136
- name : Merge label configuration files
122
137
run : |
123
138
# Merge all configuration files
124
139
shopt -s extglob
125
140
cat "${{ env.CONFIGURATIONS_FOLDER }}"/*.@(yml|yaml) > "${{ env.MERGED_CONFIGURATION_PATH }}"
126
141
127
142
- name : Install github-label-sync
128
- run : sudo npm install --global github-label-sync
143
+ run : npm install
129
144
130
145
- name : Sync labels
131
146
env :
132
147
GITHUB_ACCESS_TOKEN : ${{ secrets.GITHUB_TOKEN }}
133
148
run : |
134
149
# See: https://github.com/Financial-Times/github-label-sync
135
- github-label-sync \
136
- --labels "${{ env.MERGED_CONFIGURATION_PATH }}" \
137
- ${{ steps.dry-run.outputs.flag }} \
138
- ${{ github.repository }}
150
+ npx \
151
+ github-label-sync \
152
+ --labels "${{ env.MERGED_CONFIGURATION_PATH }}" \
153
+ ${{ steps.dry-run.outputs.flag }} \
154
+ ${{ github.repository }}
0 commit comments