Skip to content

Commit 92d8457

Browse files
committed
Add changelog feature
1 parent 64621be commit 92d8457

13 files changed

Lines changed: 373 additions & 11 deletions

File tree

.github/workflows/org-label-sync.yml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,3 +58,19 @@ jobs:
5858
DELETE_MISSING: ${{ inputs.delete_missing }}
5959
TARGET_REPOSITORIES: ${{ inputs.repositories }}
6060
run: node scripts/sync-labels.mjs
61+
62+
- name: Commit changelog
63+
if: ${{ !inputs.dry_run }}
64+
env:
65+
PUSH_TOKEN: ${{ secrets[steps.properties.outputs.label_sync_token_secret_name] }}
66+
run: |
67+
git config user.name "github-actions[bot]"
68+
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
69+
if [ -z "$(git status --porcelain -- changelogs)" ]; then
70+
echo "No changelog changes detected."
71+
exit 0
72+
fi
73+
git add changelogs
74+
git commit -m "Add Org-Label-Sync changelog [skip ci]"
75+
git remote set-url origin "https://x-access-token:${PUSH_TOKEN}@github.com/${{ github.repository }}.git"
76+
git push origin "HEAD:${{ github.event.repository.default_branch }}"

.github/workflows/remove-labels.yml

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ on:
2929
type: string
3030

3131
permissions:
32-
contents: read
32+
contents: write
3333

3434
jobs:
3535
remove-labels:
@@ -64,3 +64,18 @@ jobs:
6464
TARGET_ONLY_CLOSED_PULL_REQUESTS: ${{ inputs.target_only_closed_pull_requests }}
6565
LABEL_NAME: ${{ inputs.label_name }}
6666
run: node scripts/remove-labels.mjs
67+
68+
- name: Commit changelog
69+
env:
70+
PUSH_TOKEN: ${{ secrets[steps.properties.outputs.label_sync_token_secret_name] }}
71+
run: |
72+
git config user.name "github-actions[bot]"
73+
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
74+
if [ -z "$(git status --porcelain -- changelogs)" ]; then
75+
echo "No changelog changes detected."
76+
exit 0
77+
fi
78+
git add changelogs
79+
git commit -m "Add Remove-Labels changelog [skip ci]"
80+
git remote set-url origin "https://x-access-token:${PUSH_TOKEN}@github.com/${{ github.repository }}.git"
81+
git push origin "HEAD:${{ github.event.repository.default_branch }}"

.idea/.gitignore

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/Label_Sync_UPD.iml

Lines changed: 9 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/codeStyles/Project.xml

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/codeStyles/codeStyleConfig.xml

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/misc.xml

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/modules.xml

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/vcs.xml

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

README.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ Its job is to:
88
- validate config changes automatically
99
- sync the resulting label set across the rest of the organization
1010
- remove an exact label from issues and pull requests across the filtered repository set
11+
- write run-level changelogs for each workflow run that actually changes another repository
1112

1213
## How It Works
1314

@@ -42,11 +43,16 @@ The normal flow is:
4243
| |-- labels.jsonc
4344
| |-- properties.jsonc
4445
| `-- repository-filter.jsonc
46+
|-- changelogs/
47+
| `-- YYYY-MM-DD/
48+
| `-- workflow-run-changelog.md
4549
`-- scripts/
4650
|-- export-properties.mjs
51+
|-- remove-labels.mjs
4752
|-- sync-config-labels.mjs
4853
|-- sync-labels.mjs
4954
`-- lib/
55+
|-- changelog-utils.mjs
5056
`-- config-utils.mjs
5157
```
5258

@@ -224,6 +230,7 @@ What it does:
224230
7. Creates or updates labels from `config/labels.jsonc`
225231
8. Deletes labels listed in `config/auto-pruned-labels.jsonc`
226232
9. Optionally deletes any other unmanaged labels if `delete_missing` or `deleteMissingByDefault` is enabled
233+
10. If the run is not a dry run and at least one target repo changed, writes a changelog under `changelogs/YYYY-MM-DD/` and commits it with `[skip ci]`
227234

228235
### `Remove-Labels`
229236

@@ -249,6 +256,27 @@ What it does:
249256
4. Discovers repositories in the configured organization
250257
5. Applies `config/repository-filter.jsonc` in whitelist or blacklist mode
251258
6. Removes the exact label from the selected issues and/or pull requests in every remaining repository
259+
7. If at least one target repo changed, writes a changelog under `changelogs/YYYY-MM-DD/` and commits it with `[skip ci]`
260+
261+
## Changelogs
262+
263+
Applied changes to other repositories are documented in `changelogs/`.
264+
265+
Each changelog file is created only when a workflow actually changes at least one filtered target repository. Repositories that were included by the whitelist or not excluded by the blacklist, but had nothing to change, are not listed.
266+
267+
`Org-Label-Sync` changelogs include:
268+
269+
- created labels
270+
- updated labels, including changed fields
271+
- configured auto-pruned labels that were deleted
272+
- unmanaged labels that were deleted when delete-missing is enabled
273+
274+
`Remove-Labels` changelogs include:
275+
276+
- each issue the label was removed from
277+
- each pull request the label was removed from
278+
279+
Changelog commits use the configured full-access token and include `[skip ci]` in the commit message so they do not trigger normal workflow/check runs.
252280

253281
Notes:
254282

@@ -263,7 +291,9 @@ That token needs enough access to:
263291
- read and update labels on the source repository
264292
- discover repositories in the organization
265293
- read and update labels on target repositories
294+
- read and update issues and pull requests when running `Remove-Labels`
266295
- push config updates back to this repository when `Config-Label_Sync` changes `labels.jsonc`
296+
- push changelog commits back to this repository when an action changes another repository
267297

268298
## Setup
269299

0 commit comments

Comments
 (0)