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
- # See: https://docs.github.com/en/actions/reference/events-that-trigger-workflows
4
+ env :
5
+ CONFIGURATIONS_FOLDER : .github/label-configuration-files
6
+ CONFIGURATIONS_ARTIFACT : label-configuration-files
7
+
8
+ # See: https://docs.github.com/actions/using-workflows/events-that-trigger-workflows
5
9
on :
6
10
push :
7
11
paths :
8
- - " .github/workflows/sync-labels.ya?ml"
12
+ - " .github/workflows/sync-labels-npm .ya?ml"
9
13
- " .github/label-configuration-files/*.ya?ml"
14
+ - " .npmrc"
15
+ - " package.json"
16
+ - " package-lock.json"
10
17
pull_request :
11
18
paths :
12
- - " .github/workflows/sync-labels.ya?ml"
19
+ - " .github/workflows/sync-labels-npm .ya?ml"
13
20
- " .github/label-configuration-files/*.ya?ml"
21
+ - " .npmrc"
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
33
+ permissions :
34
+ contents : read
27
35
28
36
steps :
29
37
- name : Checkout repository
30
38
uses : actions/checkout@v4
31
39
40
+ - name : Setup Node.js
41
+ uses : actions/setup-node@v4
42
+ with :
43
+ node-version-file : package.json
44
+
32
45
- name : Download JSON schema for labels configuration file
33
46
id : download-schema
34
47
uses : carlosperate/download-file-action@v2
@@ -37,32 +50,32 @@ jobs:
37
50
location : ${{ runner.temp }}/label-configuration-schema
38
51
39
52
- name : Install JSON schema validator
40
- run : |
41
- sudo npm install \
42
- --global \
43
- ajv-cli \
44
- ajv-formats
53
+ run : npm install
45
54
46
55
- name : Validate local labels configuration
47
56
run : |
48
57
# 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}"
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}"
54
66
55
67
download :
56
68
needs : check
57
69
runs-on : ubuntu-latest
70
+ permissions : {}
58
71
59
72
strategy :
60
73
matrix :
61
74
filename :
62
75
# Filenames of the shared configurations to apply to the repository in addition to the local configuration.
63
76
# https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/sync-labels
64
- - universal.yml
65
77
- tooling.yml
78
+ - universal.yml
66
79
67
80
steps :
68
81
- name : Download
@@ -82,11 +95,14 @@ jobs:
82
95
sync :
83
96
needs : download
84
97
runs-on : ubuntu-latest
98
+ permissions :
99
+ contents : read
100
+ issues : write
85
101
86
102
steps :
87
103
- name : Set environment variables
88
104
run : |
89
- # See: https://docs.github.com/en/ actions/reference /workflow-commands-for-github-actions#setting-an-environment-variable
105
+ # See: https://docs.github.com/actions/using-workflows /workflow-commands-for-github-actions#setting-an-environment-variable
90
106
echo "MERGED_CONFIGURATION_PATH=${{ runner.temp }}/labels.yml" >> "$GITHUB_ENV"
91
107
92
108
- name : Determine whether to dry run
@@ -103,7 +119,7 @@ jobs:
103
119
run : |
104
120
# Use of this flag in the github-label-sync command will cause it to only check the validity of the
105
121
# configuration.
106
- echo "::set-output name= flag:: --dry-run"
122
+ echo "flag= --dry-run" >> $GITHUB_OUTPUT
107
123
108
124
- name : Checkout repository
109
125
uses : actions/checkout@v4
@@ -119,21 +135,27 @@ jobs:
119
135
with :
120
136
name : ${{ env.CONFIGURATIONS_ARTIFACT }}
121
137
138
+ - name : Setup Node.js
139
+ uses : actions/setup-node@v4
140
+ with :
141
+ node-version-file : package.json
142
+
122
143
- name : Merge label configuration files
123
144
run : |
124
145
# Merge all configuration files
125
146
shopt -s extglob
126
147
cat "${{ env.CONFIGURATIONS_FOLDER }}"/*.@(yml|yaml) > "${{ env.MERGED_CONFIGURATION_PATH }}"
127
148
128
149
- name : Install github-label-sync
129
- run : sudo npm install --global github-label-sync
150
+ run : npm install
130
151
131
152
- name : Sync labels
132
153
env :
133
154
GITHUB_ACCESS_TOKEN : ${{ secrets.GITHUB_TOKEN }}
134
155
run : |
135
156
# See: https://github.com/Financial-Times/github-label-sync
136
- github-label-sync \
137
- --labels "${{ env.MERGED_CONFIGURATION_PATH }}" \
138
- ${{ steps.dry-run.outputs.flag }} \
139
- ${{ github.repository }}
157
+ npx \
158
+ github-label-sync \
159
+ --labels "${{ env.MERGED_CONFIGURATION_PATH }}" \
160
+ ${{ steps.dry-run.outputs.flag }} \
161
+ ${{ github.repository }}
0 commit comments