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- # See: https://docs.github.com/en/actions/reference/events-that-trigger-workflows
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+
10+ # 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@v2
@@ -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
8696 steps :
8797 - name : Set environment variables
8898 run : |
89- # See: https://docs.github.com/en/ actions/reference /workflow-commands-for-github-actions#setting-an-environment-variable
99+ # See: https://docs.github.com/actions/using-workflows /workflow-commands-for-github-actions#setting-an-environment-variable
90100 echo "MERGED_CONFIGURATION_PATH=${{ runner.temp }}/labels.yml" >> "$GITHUB_ENV"
91101
92102 - name : Determine whether to dry run
@@ -119,21 +129,27 @@ jobs:
119129 with :
120130 name : ${{ env.CONFIGURATIONS_ARTIFACT }}
121131
132+ - name : Setup Node.js
133+ uses : actions/setup-node@v3
134+ with :
135+ node-version : ${{ env.NODE_VERSION }}
136+
122137 - name : Merge label configuration files
123138 run : |
124139 # Merge all configuration files
125140 shopt -s extglob
126141 cat "${{ env.CONFIGURATIONS_FOLDER }}"/*.@(yml|yaml) > "${{ env.MERGED_CONFIGURATION_PATH }}"
127142
128143 - name : Install github-label-sync
129- run : sudo npm install --global github-label-sync
144+ run : npm install
130145
131146 - name : Sync labels
132147 env :
133148 GITHUB_ACCESS_TOKEN : ${{ secrets.GITHUB_TOKEN }}
134149 run : |
135150 # 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 }}
151+ npx \
152+ github-label-sync \
153+ --labels "${{ env.MERGED_CONFIGURATION_PATH }}" \
154+ ${{ steps.dry-run.outputs.flag }} \
155+ ${{ github.repository }}
0 commit comments