Skip to content

Commit 87962e7

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 87962e7

File tree

4 files changed

+1043
-28
lines changed

4 files changed

+1043
-28
lines changed

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

Lines changed: 38 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,32 @@
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

4+
env:
5+
CONFIGURATIONS_FOLDER: .github/label-configuration-files
6+
CONFIGURATIONS_ARTIFACT_PREFIX: label-configuration-file-
7+
48
# See: https://docs.github.com/actions/writing-workflows/choosing-when-your-workflow-runs/events-that-trigger-workflows
59
on:
610
push:
711
paths:
8-
- ".github/workflows/sync-labels.ya?ml"
12+
- ".github/workflows/sync-labels-npm.ya?ml"
913
- ".github/label-configuration-files/*.ya?ml"
14+
- ".npmrc"
15+
- "package.json"
16+
- "package-lock.json"
1017
pull_request:
1118
paths:
12-
- ".github/workflows/sync-labels.ya?ml"
19+
- ".github/workflows/sync-labels-npm.ya?ml"
1320
- ".github/label-configuration-files/*.ya?ml"
21+
- ".npmrc"
22+
- "package.json"
23+
- "package-lock.json"
1424
schedule:
1525
# Run daily at 8 AM UTC to sync with changes to shared label configurations.
1626
- cron: "0 8 * * *"
1727
workflow_dispatch:
1828
repository_dispatch:
1929

20-
env:
21-
CONFIGURATIONS_FOLDER: .github/label-configuration-files
22-
CONFIGURATIONS_ARTIFACT_PREFIX: label-configuration-file-
23-
2430
jobs:
2531
check:
2632
runs-on: ubuntu-latest
@@ -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

Lines changed: 1 addition & 1 deletion
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)