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
22name : Sync Labels
33
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+
410# See: https://docs.github.com/actions/using-workflows/events-that-trigger-workflows
511on :
612 push :
713 paths :
8- - " .github/workflows/sync-labels.ya?ml"
14+ - " .github/workflows/sync-labels-npm .ya?ml"
915 - " .github/label-configuration-files/*.ya?ml"
16+ - " package.json"
17+ - " package-lock.json"
1018 pull_request :
1119 paths :
12- - " .github/workflows/sync-labels.ya?ml"
20+ - " .github/workflows/sync-labels-npm .ya?ml"
1321 - " .github/label-configuration-files/*.ya?ml"
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 : label-configuration-files
23-
2430jobs :
2531 check :
2632 runs-on : ubuntu-latest
2935 - name : Checkout repository
3036 uses : actions/checkout@v3
3137
38+ - name : Setup Node.js
39+ uses : actions/setup-node@v3
40+ with :
41+ node-version : ${{ env.NODE_VERSION }}
42+
3243 - name : Download JSON schema for labels configuration file
3344 id : download-schema
3445 uses : carlosperate/download-file-action@v1
@@ -37,20 +48,19 @@ jobs:
3748 location : ${{ runner.temp }}/label-configuration-schema
3849
3950 - name : Install JSON schema validator
40- run : |
41- sudo npm install \
42- --global \
43- ajv-cli \
44- ajv-formats
51+ run : npm install
4552
4653 - name : Validate local labels configuration
4754 run : |
4855 # 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}"
5464
5565 download :
5666 needs : check
@@ -118,21 +128,27 @@ jobs:
118128 with :
119129 name : ${{ env.CONFIGURATIONS_ARTIFACT }}
120130
131+ - name : Setup Node.js
132+ uses : actions/setup-node@v3
133+ with :
134+ node-version : ${{ env.NODE_VERSION }}
135+
121136 - name : Merge label configuration files
122137 run : |
123138 # Merge all configuration files
124139 shopt -s extglob
125140 cat "${{ env.CONFIGURATIONS_FOLDER }}"/*.@(yml|yaml) > "${{ env.MERGED_CONFIGURATION_PATH }}"
126141
127142 - name : Install github-label-sync
128- run : sudo npm install --global github-label-sync
143+ run : npm install
129144
130145 - name : Sync labels
131146 env :
132147 GITHUB_ACCESS_TOKEN : ${{ secrets.GITHUB_TOKEN }}
133148 run : |
134149 # 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