Skip to content

Commit 554bde5

Browse files
committed
Rebuild release wiki refreshes from the main pointer (#312)
1 parent 106e64d commit 554bde5

4 files changed

Lines changed: 34 additions & 17 deletions

File tree

.github/actions/wiki/refresh-release-pointer/run.sh

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -9,26 +9,15 @@ publish_branch="${INPUT_PUBLISH_BRANCH:-master}"
99
commit_message="${INPUT_COMMIT_MESSAGE:-Refresh wiki docs after merged release}"
1010

1111
git -C "${target}" fetch origin "${publish_branch}"
12-
13-
if ! git -C "${target}" switch -C "${publish_branch}" --track "origin/${publish_branch}" >/dev/null 2>&1; then
14-
git -C "${target}" switch "${publish_branch}" >/dev/null 2>&1
15-
fi
16-
17-
git -C "${target}" reset --hard "origin/${publish_branch}"
12+
git -C "${target}" reset --hard HEAD
1813
git -C "${target}" clean -fd
1914

2015
dev-tools wiki --target="${target}"
2116

2217
if [ -z "$(git -C "${target}" status --porcelain)" ]; then
23-
pointer_changed="false"
24-
25-
if ! git diff --quiet -- "${target}"; then
26-
pointer_changed="true"
27-
fi
28-
2918
{
3019
echo "published=false"
31-
echo "pointer-changed=${pointer_changed}"
20+
echo "pointer-changed=false"
3221
echo "publish-sha=$(git -C "${target}" rev-parse HEAD)"
3322
} >> "${GITHUB_OUTPUT}"
3423

@@ -39,7 +28,7 @@ git -C "${target}" config user.name "${GIT_AUTHOR_NAME:-github-actions[bot]}"
3928
git -C "${target}" config user.email "${GIT_AUTHOR_EMAIL:-41898282+github-actions[bot]@users.noreply.github.com}"
4029
git -C "${target}" add -A
4130
git -C "${target}" commit -m "${commit_message}"
42-
git -C "${target}" push origin "HEAD:${publish_branch}"
31+
git -C "${target}" push --force-with-lease origin "HEAD:${publish_branch}"
4332

4433
pointer_changed="false"
4534

.github/workflows/wiki-maintenance.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,13 +120,14 @@ jobs:
120120
- name: Explain release publish handling
121121
env:
122122
RELEASE_BRANCH: ${{ github.event.pull_request.head.ref }}
123+
SOURCE_BRANCH: ${{ github.event.pull_request.base.ref }}
123124
run: |
124125
{
125126
printf '## Wiki Publish Summary\n\n'
126-
printf -- '- Publish branch: `master`\n'
127+
printf -- '- Source branch: `%s`\n' "$SOURCE_BRANCH"
127128
printf -- '- Preview branch: `%s`\n' "${WIKI_PREVIEW_BRANCH}"
128129
printf -- '- Release branch: `%s`\n' "$RELEASE_BRANCH"
129-
printf -- '- Action: skipped preview-branch publication because merged release branches are refreshed from the authoritative released state by `changelog.yml`.\n'
130+
printf -- '- Action: skipped preview-branch publication because merged release branches are rebuilt from the `.github/wiki` pointer recorded on `%s` by `changelog.yml`.\n' "$SOURCE_BRANCH"
130131
printf -- '- Preview cleanup: `%s`\n' "${{ steps.cleanup_preview.outputs.deleted == 'true' && 'deleted immediately' || 'not present' }}"
131132
} >> "$GITHUB_STEP_SUMMARY"
132133

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1010
### Fixed
1111

1212
- Keep reusable-workflow retry automation from failing on unreadable child-job logs, while moving release-branch wiki publication to changelog-driven release refreshes that republish wiki content and reconcile the parent `.github/wiki` pointer from the authoritative released state (#309)
13+
- Rebuild release-time wiki publication from the `.github/wiki` pointer already recorded on `main`, force-push the regenerated wiki branch only when the rebuilt content changes, and align merged-release wiki maintenance summaries with `main` as the source branch (#312)
1314

1415
## [1.24.5] - 2026-04-30
1516

tests/GitHubActions/RefreshReleaseWikiPointerActionTest.php

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ public function refreshWillSkipPublicationWhenTheRenderedWikiDoesNotChange(): vo
123123
* @return void
124124
*/
125125
#[Test]
126-
public function refreshWillReportPointerDriftWhenTheWikiRemoteAdvancedWithoutNewRenderedChanges(): void
126+
public function refreshWillIgnoreRemotePointerDriftWhenTheRenderedWikiDoesNotChange(): void
127127
{
128128
$workspace = $this->createWorkspaceWithWikiSubmodule();
129129
$this->advanceWikiRemote();
@@ -136,7 +136,33 @@ public function refreshWillReportPointerDriftWhenTheWikiRemoteAdvancedWithoutNew
136136
$status = $this->runProcess(['git', 'status', '--short', '.github/wiki'], $workspace);
137137

138138
self::assertSame('false', $outputs['published']);
139+
self::assertSame('false', $outputs['pointer-changed']);
140+
self::assertSame('', trim($status->getOutput()));
141+
}
142+
143+
/**
144+
* @return void
145+
*/
146+
#[Test]
147+
public function refreshWillRepublishFromTheCheckedInPointerWhenThePublishedWikiBranchAdvanced(): void
148+
{
149+
$workspace = $this->createWorkspaceWithWikiSubmodule();
150+
$this->advanceWikiRemote();
151+
$this->createMockDevToolsBinary(true);
152+
$outputFile = $this->workspace . '/github-output';
153+
154+
$this->runAction($workspace, $outputFile);
155+
156+
$outputs = $this->parseKeyValueFile($outputFile);
157+
$status = $this->runProcess(['git', 'status', '--short', '.github/wiki'], $workspace);
158+
$remoteHead = $this->runProcess(
159+
['git', 'rev-parse', 'refs/heads/master'],
160+
$this->workspace . '/wiki-remote.git',
161+
);
162+
163+
self::assertSame('true', $outputs['published']);
139164
self::assertSame('true', $outputs['pointer-changed']);
165+
self::assertSame(trim($outputs['publish-sha']), trim($remoteHead->getOutput()));
140166
self::assertStringContainsString('.github/wiki', $status->getOutput());
141167
}
142168

0 commit comments

Comments
 (0)