Skip to content

Commit 404f22a

Browse files
authored
Add CI workflow to synchronize with shared repository labels (#21)
On every push that changes relevant files, and periodically, configure the repository's issue and pull request labels according to the universal, shared, and local label configuration files.
1 parent 3437c72 commit 404f22a

File tree

2 files changed

+162
-1
lines changed

2 files changed

+162
-1
lines changed

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

+160
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,160 @@
1+
# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/sync-labels-npm.md
2+
name: Sync Labels
3+
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
11+
on:
12+
push:
13+
paths:
14+
- ".github/workflows/sync-labels-npm.ya?ml"
15+
- ".github/label-configuration-files/*.ya?ml"
16+
- "package.json"
17+
- "package-lock.json"
18+
pull_request:
19+
paths:
20+
- ".github/workflows/sync-labels-npm.ya?ml"
21+
- ".github/label-configuration-files/*.ya?ml"
22+
- "package.json"
23+
- "package-lock.json"
24+
schedule:
25+
# Run daily at 8 AM UTC to sync with changes to shared label configurations.
26+
- cron: "0 8 * * *"
27+
workflow_dispatch:
28+
repository_dispatch:
29+
30+
jobs:
31+
check:
32+
runs-on: ubuntu-latest
33+
permissions:
34+
contents: read
35+
36+
steps:
37+
- name: Checkout repository
38+
uses: actions/checkout@v4
39+
40+
- name: Setup Node.js
41+
uses: actions/setup-node@v4
42+
with:
43+
node-version: ${{ env.NODE_VERSION }}
44+
45+
- name: Download JSON schema for labels configuration file
46+
id: download-schema
47+
uses: carlosperate/download-file-action@v2
48+
with:
49+
file-url: https://raw.githubusercontent.com/arduino/tooling-project-assets/main/workflow-templates/assets/sync-labels/arduino-tooling-gh-label-configuration-schema.json
50+
location: ${{ runner.temp }}/label-configuration-schema
51+
52+
- name: Install JSON schema validator
53+
run: npm install
54+
55+
- name: Validate local labels configuration
56+
run: |
57+
# See: https://github.com/ajv-validator/ajv-cli#readme
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}"
66+
67+
download:
68+
needs: check
69+
runs-on: ubuntu-latest
70+
permissions: {}
71+
72+
strategy:
73+
matrix:
74+
filename:
75+
# Filenames of the shared configurations to apply to the repository in addition to the local configuration.
76+
# https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/sync-labels
77+
- universal.yml
78+
79+
steps:
80+
- name: Download
81+
uses: carlosperate/download-file-action@v2
82+
with:
83+
file-url: https://raw.githubusercontent.com/arduino/tooling-project-assets/main/workflow-templates/assets/sync-labels/${{ matrix.filename }}
84+
85+
- name: Pass configuration files to next job via workflow artifact
86+
uses: actions/upload-artifact@v3
87+
with:
88+
path: |
89+
*.yaml
90+
*.yml
91+
if-no-files-found: error
92+
name: ${{ env.CONFIGURATIONS_ARTIFACT }}
93+
94+
sync:
95+
needs: download
96+
runs-on: ubuntu-latest
97+
permissions:
98+
contents: read
99+
issues: write
100+
101+
steps:
102+
- name: Set environment variables
103+
run: |
104+
# See: https://docs.github.com/actions/using-workflows/workflow-commands-for-github-actions#setting-an-environment-variable
105+
echo "MERGED_CONFIGURATION_PATH=${{ runner.temp }}/labels.yml" >> "$GITHUB_ENV"
106+
107+
- name: Determine whether to dry run
108+
id: dry-run
109+
if: >
110+
github.event_name == 'pull_request' ||
111+
(
112+
(
113+
github.event_name == 'push' ||
114+
github.event_name == 'workflow_dispatch'
115+
) &&
116+
github.ref != format('refs/heads/{0}', github.event.repository.default_branch)
117+
)
118+
run: |
119+
# Use of this flag in the github-label-sync command will cause it to only check the validity of the
120+
# configuration.
121+
echo "flag=--dry-run" >> $GITHUB_OUTPUT
122+
123+
- name: Checkout repository
124+
uses: actions/checkout@v4
125+
126+
- name: Download configuration files artifact
127+
uses: actions/download-artifact@v3
128+
with:
129+
name: ${{ env.CONFIGURATIONS_ARTIFACT }}
130+
path: ${{ env.CONFIGURATIONS_FOLDER }}
131+
132+
- name: Remove unneeded artifact
133+
uses: geekyeggo/delete-artifact@v2
134+
with:
135+
name: ${{ env.CONFIGURATIONS_ARTIFACT }}
136+
137+
- name: Setup Node.js
138+
uses: actions/setup-node@v4
139+
with:
140+
node-version: ${{ env.NODE_VERSION }}
141+
142+
- name: Merge label configuration files
143+
run: |
144+
# Merge all configuration files
145+
shopt -s extglob
146+
cat "${{ env.CONFIGURATIONS_FOLDER }}"/*.@(yml|yaml) > "${{ env.MERGED_CONFIGURATION_PATH }}"
147+
148+
- name: Install github-label-sync
149+
run: npm install
150+
151+
- name: Sync labels
152+
env:
153+
GITHUB_ACCESS_TOKEN: ${{ secrets.GITHUB_TOKEN }}
154+
run: |
155+
# See: https://github.com/Financial-Times/github-label-sync
156+
npx \
157+
github-label-sync \
158+
--labels "${{ env.MERGED_CONFIGURATION_PATH }}" \
159+
${{ steps.dry-run.outputs.flag }} \
160+
${{ github.repository }}

README.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
Arduino_GigaDisplay
22
===================
33
[![Spell Check status](https://github.com/arduino-libraries/Arduino_GigaDisplay/actions/workflows/spell-check-task.yml/badge.svg)](https://github.com/arduino-libraries/Arduino_GigaDisplay/actions/workflows/spell-check-task.yml)
4+
[![Sync Labels status](https://github.com/arduino-libraries/Arduino_GigaDisplay/actions/workflows/sync-labels-npm.yml/badge.svg)](https://github.com/arduino-libraries/Arduino_GigaDisplay/actions/workflows/sync-labels-npm.yml)
45

56
This library contains a set of examples to use the [GIGA Display Shield](docs.arduino.cc/hardware/giga-display-shield). Upon installing this library from the Arduino IDE, the following libraries will also be installed:
67
- [ArduinoGraphics](https://github.com/arduino-libraries/ArduinoGraphics)
@@ -14,4 +15,4 @@ It will also install the [lvgl](https://github.com/lvgl/lvgl) library, which is
1415
1516
## GigaDisplayRGB
1617

17-
This library has a class called `GigaDisplayRGB`, which is used to control the built-in RGB on the GIGA Display Shield via the IS31FL3197 driver (I2C).
18+
This library has a class called `GigaDisplayRGB`, which is used to control the built-in RGB on the GIGA Display Shield via the IS31FL3197 driver (I2C).

0 commit comments

Comments
 (0)