Skip to content

Commit 187f0d8

Browse files
CopilotIsthimius
andauthored
chore: restore PR-based changelog automation with auto-merge
Co-authored-by: Isthimius <11380950+Isthimius@users.noreply.github.com>
1 parent 23fd2c2 commit 187f0d8

2 files changed

Lines changed: 55 additions & 11 deletions

File tree

.github/workflows/changelog-master.yml

Lines changed: 53 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -295,18 +295,62 @@ jobs:
295295
validate_changes
296296
echo "has_changes=true" >> "$GITHUB_OUTPUT"
297297
298-
- name: Commit and push changelog updates
298+
- name: Open changelog update pull request
299299
if: steps.changes.outputs.has_changes == 'true'
300-
shell: bash
301-
run: |
302-
git config user.name "github-actions[bot]"
303-
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
304-
git add -- CHANGELOG.md ':(glob)**/CHANGELOG.md'
305-
git commit -m "docs: update unreleased changelogs [skip release notes]"
306-
git push origin HEAD:master
300+
id: changelog_pr
301+
uses: peter-evans/create-pull-request@5f6978faf089d4d20b00c7766989d076bb2fc7f1 # v8.1.1
302+
with:
303+
token: ${{ github.token }}
304+
branch: automation/update-changelogs
305+
base: master
306+
delete-branch: true
307+
commit-message: "docs: update unreleased changelogs [skip release notes]"
308+
title: "docs: update unreleased changelogs"
309+
body: |
310+
Automated changelog refresh for commits merged into `master`.
311+
author: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
312+
committer: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
313+
add-paths: |
314+
CHANGELOG.md
315+
**/CHANGELOG.md
316+
317+
- name: Enable auto-merge for changelog pull request
318+
if: steps.changes.outputs.has_changes == 'true' && steps.changelog_pr.outputs.pull-request-number != ''
319+
uses: actions/github-script@v7
320+
with:
321+
script: |
322+
const owner = context.repo.owner;
323+
const repo = context.repo.repo;
324+
const pull_number = Number("${{ steps.changelog_pr.outputs.pull-request-number }}");
325+
const { data: pull } = await github.rest.pulls.get({
326+
owner,
327+
repo,
328+
pull_number
329+
});
330+
331+
if (pull.state !== "open") {
332+
core.info(`Changelog PR #${pull_number} is not open; skipping auto-merge enablement.`);
333+
return;
334+
}
335+
336+
if (pull.auto_merge) {
337+
core.info(`Auto-merge already enabled for changelog PR #${pull_number}.`);
338+
return;
339+
}
340+
341+
await github.graphql(
342+
`mutation EnableAutoMerge($pullRequestId: ID!) {
343+
enablePullRequestAutoMerge(input: { pullRequestId: $pullRequestId, mergeMethod: SQUASH }) {
344+
pullRequest { number }
345+
}
346+
}`,
347+
{ pullRequestId: pull.node_id }
348+
);
349+
350+
core.info(`Enabled auto-merge for changelog PR #${pull_number}.`);
307351
308352
- name: Close stale changelog automation pull requests
309-
if: always()
353+
if: steps.changes.outputs.has_changes != 'true'
310354
uses: actions/github-script@v7
311355
with:
312356
script: |

Tooling/scripts/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ Packs `Tooling/Gondwana.Templates` and reinstalls the exact freshly packed templ
131131

132132
### `Generate-Project-Changelogs.ps1`
133133

134-
Generates a `CHANGELOG.md` for each library project using [`git-cliff`](https://git-cliff.org/), filtering commits by changed file paths so each project only shows the changes that affected it. This is the standard monorepo approach described in the git-cliff docs. `release.ps1` invokes this script as part of the release flow, and `.github/workflows/changelog-master.yml` refreshes the running unreleased sections after non-changelog pushes to `master` before auto-committing the resulting changelog updates back to `master`.
134+
Generates a `CHANGELOG.md` for each library project using [`git-cliff`](https://git-cliff.org/), filtering commits by changed file paths so each project only shows the changes that affected it. This is the standard monorepo approach described in the git-cliff docs. `release.ps1` invokes this script as part of the release flow, and `.github/workflows/changelog-master.yml` refreshes the running unreleased sections after non-changelog pushes to `master` before opening/updating an automation PR that is configured for auto-merge.
135135

136136
**What it does:**
137137
1. Iterates over the default set of library/tooling projects (all `Gondwana.*` projects and `Tooling/*` projects; Demos and `Gondwana.Tests` are excluded).
@@ -176,7 +176,7 @@ Generates a `CHANGELOG.md` for each library project using [`git-cliff`](https://
176176

177177
### `Generate-Root-Changelog.ps1`
178178

179-
Regenerates only the repository-level `CHANGELOG.md`'s leading derived section while preserving all existing released history exactly. Its entries are grouped by project/area in the same format used by release notes. `.github/workflows/changelog-master.yml` runs this script alongside `Generate-Project-Changelogs.ps1` after non-changelog pushes to `master` before auto-committing any generated changelog changes.
179+
Regenerates only the repository-level `CHANGELOG.md`'s leading derived section while preserving all existing released history exactly. Its entries are grouped by project/area in the same format used by release notes. `.github/workflows/changelog-master.yml` runs this script alongside `Generate-Project-Changelogs.ps1` after non-changelog pushes to `master` before opening/updating an automation PR that is configured for auto-merge.
180180

181181
**What it does:**
182182
1. Loads the project/area definitions from `Changelog-ProjectGroups.ps1`.

0 commit comments

Comments
 (0)