Skip to content

Commit 8285152

Browse files
committed
Add remove-labels workflow
1 parent 5a6982a commit 8285152

4 files changed

Lines changed: 419 additions & 1 deletion

File tree

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
name: remove-labels
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
run_on_issues:
7+
description: "Remove the label from issues in the configured repository set"
8+
required: true
9+
type: boolean
10+
default: true
11+
closed_only:
12+
description: "When Run on Issues is enabled, only target closed issues"
13+
required: true
14+
type: boolean
15+
default: false
16+
run_on_pull_requests:
17+
description: "Remove the label from pull requests in the configured repository set"
18+
required: true
19+
type: boolean
20+
default: false
21+
merged_only:
22+
description: "When Run on Pull Requests is enabled, only target merged pull requests"
23+
required: true
24+
type: boolean
25+
default: false
26+
label_name:
27+
description: "Exact label name to remove"
28+
required: true
29+
type: string
30+
31+
permissions:
32+
contents: read
33+
34+
jobs:
35+
remove-labels:
36+
runs-on: ubuntu-latest
37+
38+
steps:
39+
- name: Check out latest default branch
40+
uses: actions/checkout@v4
41+
with:
42+
ref: ${{ github.event.repository.default_branch }}
43+
44+
- name: Set up Node.js
45+
uses: actions/setup-node@v4
46+
with:
47+
node-version: "20"
48+
49+
- name: Load properties
50+
id: properties
51+
env:
52+
GITHUB_REPOSITORY: ${{ github.repository }}
53+
run: node scripts/export-properties.mjs
54+
55+
- name: Validate config
56+
run: node scripts/remove-labels.mjs --validate-only
57+
58+
- name: Remove labels from selected items
59+
env:
60+
LABEL_SYNC_TOKEN: ${{ secrets[steps.properties.outputs.label_sync_token_secret_name] }}
61+
RUN_ON_ISSUES: ${{ inputs.run_on_issues }}
62+
CLOSED_ONLY: ${{ inputs.closed_only }}
63+
RUN_ON_PULL_REQUESTS: ${{ inputs.run_on_pull_requests }}
64+
MERGED_ONLY: ${{ inputs.merged_only }}
65+
LABEL_NAME: ${{ inputs.label_name }}
66+
run: node scripts/remove-labels.mjs

.github/workflows/validate-configs.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,3 +23,6 @@ jobs:
2323

2424
- name: Validate label sync configuration
2525
run: node scripts/sync-labels.mjs --validate-only
26+
27+
- name: Validate remove-labels configuration
28+
run: node scripts/remove-labels.mjs --validate-only

README.md

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,16 @@ Its job is to:
77
- keep this repo's label config in sync with the labels currently defined on the repo
88
- validate config changes automatically
99
- sync the resulting label set across the rest of the organization
10+
- remove an exact label from issues and pull requests across the filtered repository set
1011

1112
## How It Works
1213

13-
This repo uses three workflows:
14+
This repo uses four workflows:
1415

1516
1. `Config-Label_Sync`
1617
2. `Validate-Configs`
1718
3. `Org-Label-Sync`
19+
4. `remove-labels`
1820

1921
The normal flow is:
2022

@@ -33,6 +35,7 @@ The normal flow is:
3335
| `-- workflows/
3436
| |-- config-label-sync.yml
3537
| |-- org-label-sync.yml
38+
| |-- remove-labels.yml
3639
| `-- validate-configs.yml
3740
|-- config/
3841
| |-- auto-pruned-labels.jsonc
@@ -194,6 +197,7 @@ Validation includes:
194197
- invalid colors
195198
- invalid repo names
196199
- overlap detection between `labels.jsonc` and `auto-pruned-labels.jsonc`
200+
- validation for the shared config used by `remove-labels`
197201

198202
### `Org-Label-Sync`
199203

@@ -221,6 +225,35 @@ What it does:
221225
8. Deletes labels listed in `config/auto-pruned-labels.jsonc`
222226
9. Optionally deletes any other unmanaged labels if `delete_missing` or `deleteMissingByDefault` is enabled
223227

228+
### `remove-labels`
229+
230+
File: `.github/workflows/remove-labels.yml`
231+
232+
Trigger:
233+
234+
- manual via `workflow_dispatch`
235+
236+
Inputs:
237+
238+
- `run_on_issues`: remove the label from matching issues
239+
- `closed_only`: when `run_on_issues` is enabled, only target closed issues
240+
- `run_on_pull_requests`: remove the label from matching pull requests
241+
- `merged_only`: when `run_on_pull_requests` is enabled, only target merged pull requests
242+
- `label_name`: exact label name to remove
243+
244+
What it does:
245+
246+
1. Checks out the latest default branch
247+
2. Loads the org name and token secret name from `config/properties.jsonc`
248+
3. Validates the shared config inputs used for repo discovery
249+
4. Discovers repositories in the configured organization
250+
5. Applies `config/repository-filter.jsonc` in whitelist or blacklist mode
251+
6. Removes the exact label from the selected issues and/or pull requests in every remaining repository
252+
253+
Notes:
254+
255+
- GitHub Actions does not currently support conditionally hiding or nesting `workflow_dispatch` inputs, so `closed_only` and `merged_only` can be described as dependent toggles but not visually tucked under their parent checkboxes.
256+
224257
## Token Requirements
225258

226259
Create a repository secret whose name matches `labelSyncTokenSecretName` in `config/properties.jsonc`.

0 commit comments

Comments
 (0)