Skip to content

Commit 4b8be67

Browse files
committed
Migrate to npm-managed GitHub label sync infrastructure
Several tools are used by the "Sync Labels" workflow. The new approach is to specify the version of the tools via the standard npm metadata files (package.json + package-lock.json), providing the following benefits: - Enables automated updates via Dependabot PRs - Enables automated vulnerability alerts
1 parent cf59441 commit 4b8be67

File tree

4 files changed

+1039
-24
lines changed

4 files changed

+1039
-24
lines changed

.github/workflows/sync-labels.yml renamed to .github/workflows/sync-labels-npm.yml

+34-18
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,22 @@
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
22
name: Sync Labels
33

44
# See: https://docs.github.com/actions/writing-workflows/choosing-when-your-workflow-runs/events-that-trigger-workflows
55
on:
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 * * *"
@@ -31,6 +37,11 @@ jobs:
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 }}

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
[![Check Workflows status](https://github.com/arduino/arduino-lint/actions/workflows/check-workflows-task.yml/badge.svg)](https://github.com/arduino/arduino-lint/actions/workflows/check-workflows-task.yml)
2020
[![Check Shell Scripts status](https://github.com/arduino/arduino-lint/actions/workflows/check-shell-task.yml/badge.svg)](https://github.com/arduino/arduino-lint/actions/workflows/check-shell-task.yml)
2121
[![Check Certificates status](https://github.com/arduino/arduino-lint/actions/workflows/check-certificates.yml/badge.svg)](https://github.com/arduino/arduino-lint/actions/workflows/check-certificates.yml)
22-
[![Sync Labels status](https://github.com/arduino/arduino-lint/actions/workflows/sync-labels.yml/badge.svg)](https://github.com/arduino/arduino-lint/actions/workflows/sync-labels.yml)
22+
[![Sync Labels status](https://github.com/arduino/arduino-lint/actions/workflows/sync-labels-npm.yml/badge.svg)](https://github.com/arduino/arduino-lint/actions/workflows/sync-labels-npm.yml)
2323

2424
**Arduino Lint** is a command line tool that checks for common problems in [Arduino](https://www.arduino.cc/) projects:
2525

0 commit comments

Comments
 (0)