From 9a8b8e814524e065d591827972c42013ae40bb9a Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 3 Feb 2026 22:19:44 +0000 Subject: [PATCH 1/5] Initial plan From b1b5d4713de0638d79fa954d9c9278df9984bcdb Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 3 Feb 2026 22:22:31 +0000 Subject: [PATCH 2/5] Enhance publish-docs workflow to include upstream PR/commit details Co-authored-by: willtsai <28876888+willtsai@users.noreply.github.com> --- .github/workflows/publish-docs.yaml | 81 ++++++++++++++++++++++++++--- 1 file changed, 73 insertions(+), 8 deletions(-) diff --git a/.github/workflows/publish-docs.yaml b/.github/workflows/publish-docs.yaml index bbe3ffeb87..ef3391e844 100644 --- a/.github/workflows/publish-docs.yaml +++ b/.github/workflows/publish-docs.yaml @@ -146,6 +146,77 @@ jobs: cd docs git status --porcelain -unormal -- *.md + # Prepare PR context information based on trigger type + - name: Prepare PR context + id: pr-context + if: github.event_name == 'push' || (github.event_name == 'workflow_dispatch' && github.event.inputs.open_pull_request == 'true') + run: | + # Determine the source of this workflow run + if [[ "${{ github.event_name }}" == "push" ]]; then + # Triggered by a push to main or release branch + # Extract commit information + cd radius + COMMIT_MESSAGE=$(git log -1 --pretty=format:"%s" ${{ github.sha }}) + COMMIT_AUTHOR=$(git log -1 --pretty=format:"%an" ${{ github.sha }}) + COMMIT_AUTHOR_EMAIL=$(git log -1 --pretty=format:"%ae" ${{ github.sha }}) + + # Check if this is a merge commit from a PR (GitHub creates merge commits with specific format) + # Format: "Merge pull request #123 from user/branch" or "Title (#123)" + if [[ "$COMMIT_MESSAGE" =~ \(#([0-9]+)\)$ ]]; then + # Extract PR number from commit message + PR_NUMBER="${BASH_REMATCH[1]}" + + # For merged PRs, try to get the PR title (everything before " (#123)") + PR_TITLE="${COMMIT_MESSAGE% (#$PR_NUMBER)}" + + echo "pr-title=Update auto-generated documentation (PR #$PR_NUMBER)" >> $GITHUB_OUTPUT + echo "pr-body<> $GITHUB_OUTPUT + echo "## Autogenerated PR" >> $GITHUB_OUTPUT + echo "" >> $GITHUB_OUTPUT + echo "This PR updates the auto-generated reference documentation." >> $GITHUB_OUTPUT + echo "" >> $GITHUB_OUTPUT + echo "### Triggered by" >> $GITHUB_OUTPUT + echo "**Pull Request:** [#$PR_NUMBER - $PR_TITLE](https://github.com/${{ github.repository }}/pull/$PR_NUMBER)" >> $GITHUB_OUTPUT + echo "**Branch:** \`${GITHUB_REF##*/}\`" >> $GITHUB_OUTPUT + echo "**Commit:** [\`${{ github.sha }}\`](https://github.com/${{ github.repository }}/commit/${{ github.sha }})" >> $GITHUB_OUTPUT + echo "**Author:** $COMMIT_AUTHOR" >> $GITHUB_OUTPUT + echo "EOF" >> $GITHUB_OUTPUT + else + # Regular push commit (not from a PR merge) + echo "pr-title=Update auto-generated documentation (${GITHUB_REF##*/})" >> $GITHUB_OUTPUT + echo "pr-body<> $GITHUB_OUTPUT + echo "## Autogenerated PR" >> $GITHUB_OUTPUT + echo "" >> $GITHUB_OUTPUT + echo "This PR updates the auto-generated reference documentation." >> $GITHUB_OUTPUT + echo "" >> $GITHUB_OUTPUT + echo "### Triggered by" >> $GITHUB_OUTPUT + echo "**Branch:** \`${GITHUB_REF##*/}\`" >> $GITHUB_OUTPUT + echo "**Commit:** [\`${{ github.sha }}\`](https://github.com/${{ github.repository }}/commit/${{ github.sha }})" >> $GITHUB_OUTPUT + echo "**Author:** $COMMIT_AUTHOR" >> $GITHUB_OUTPUT + echo "**Message:** $COMMIT_MESSAGE" >> $GITHUB_OUTPUT + echo "EOF" >> $GITHUB_OUTPUT + fi + else + # Triggered by workflow_dispatch + cd radius + COMMIT_MESSAGE=$(git log -1 --pretty=format:"%s" ${{ github.sha }}) + COMMIT_AUTHOR=$(git log -1 --pretty=format:"%an" ${{ github.sha }}) + + echo "pr-title=Update auto-generated documentation (manual trigger)" >> $GITHUB_OUTPUT + echo "pr-body<> $GITHUB_OUTPUT + echo "## Autogenerated PR" >> $GITHUB_OUTPUT + echo "" >> $GITHUB_OUTPUT + echo "This PR updates the auto-generated reference documentation." >> $GITHUB_OUTPUT + echo "" >> $GITHUB_OUTPUT + echo "### Triggered by" >> $GITHUB_OUTPUT + echo "**Trigger:** Manual workflow dispatch" >> $GITHUB_OUTPUT + echo "**Triggered by:** @${{ github.actor }}" >> $GITHUB_OUTPUT + echo "**Branch:** \`${GITHUB_REF##*/}\`" >> $GITHUB_OUTPUT + echo "**Commit:** [\`${{ github.sha }}\`](https://github.com/${{ github.repository }}/commit/${{ github.sha }})" >> $GITHUB_OUTPUT + echo "**Commit Message:** $COMMIT_MESSAGE" >> $GITHUB_OUTPUT + echo "EOF" >> $GITHUB_OUTPUT + fi + - name: Create pull request if: github.event_name == 'push' || (github.event_name == 'workflow_dispatch' && github.event.inputs.open_pull_request == 'true') uses: peter-evans/create-pull-request@c0f553fe549906ede9cf27b5156039d195d2ece0 # v8.1.0 @@ -159,13 +230,7 @@ jobs: signoff: true branch: reference-cli/patch-${{ github.sha }} delete-branch: true - title: | - Update auto-generated documentation - body: | - ## Autogenerated PR - - This PR updates the auto-generated reference documentation. - - GitHub SHA: ${{ github.sha }} + title: ${{ steps.pr-context.outputs.pr-title }} + body: ${{ steps.pr-context.outputs.pr-body }} commit-message: | Autogenerate reference docs From 57ff5ef42fa8e7dc7dcdbce5b9afab505a40addc Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 3 Feb 2026 22:23:28 +0000 Subject: [PATCH 3/5] Add documentation for PR context extraction logic Co-authored-by: willtsai <28876888+willtsai@users.noreply.github.com> --- .github/workflows/publish-docs.yaml | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/.github/workflows/publish-docs.yaml b/.github/workflows/publish-docs.yaml index ef3391e844..687505d876 100644 --- a/.github/workflows/publish-docs.yaml +++ b/.github/workflows/publish-docs.yaml @@ -147,6 +147,17 @@ jobs: git status --porcelain -unormal -- *.md # Prepare PR context information based on trigger type + # This step captures details about what triggered the workflow and formats them + # into a meaningful PR title and body for the auto-generated docs PR. + # + # Scenarios handled: + # 1. Push events from merged PRs (detected by "(#123)" pattern in commit message) + # - Extracts PR number and title from the commit message + # - Creates a link back to the original PR + # 2. Push events from direct commits (no PR pattern in message) + # - Includes branch name, commit SHA, author, and commit message + # 3. Manual workflow_dispatch events + # - Includes who triggered it and the current branch/commit - name: Prepare PR context id: pr-context if: github.event_name == 'push' || (github.event_name == 'workflow_dispatch' && github.event.inputs.open_pull_request == 'true') From 6605632ff8f40a34860baf2f6177fe43867e5a0d Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 3 Feb 2026 22:25:17 +0000 Subject: [PATCH 4/5] Address code review feedback: remove unused variable and avoid duplication Co-authored-by: willtsai <28876888+willtsai@users.noreply.github.com> --- .github/workflows/publish-docs.yaml | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/.github/workflows/publish-docs.yaml b/.github/workflows/publish-docs.yaml index 687505d876..1094997111 100644 --- a/.github/workflows/publish-docs.yaml +++ b/.github/workflows/publish-docs.yaml @@ -162,15 +162,16 @@ jobs: id: pr-context if: github.event_name == 'push' || (github.event_name == 'workflow_dispatch' && github.event.inputs.open_pull_request == 'true') run: | + # Change to radius directory to extract commit information + cd radius + + # Extract commit information + COMMIT_MESSAGE=$(git log -1 --pretty=format:"%s" ${{ github.sha }}) + COMMIT_AUTHOR=$(git log -1 --pretty=format:"%an" ${{ github.sha }}) + # Determine the source of this workflow run if [[ "${{ github.event_name }}" == "push" ]]; then # Triggered by a push to main or release branch - # Extract commit information - cd radius - COMMIT_MESSAGE=$(git log -1 --pretty=format:"%s" ${{ github.sha }}) - COMMIT_AUTHOR=$(git log -1 --pretty=format:"%an" ${{ github.sha }}) - COMMIT_AUTHOR_EMAIL=$(git log -1 --pretty=format:"%ae" ${{ github.sha }}) - # Check if this is a merge commit from a PR (GitHub creates merge commits with specific format) # Format: "Merge pull request #123 from user/branch" or "Title (#123)" if [[ "$COMMIT_MESSAGE" =~ \(#([0-9]+)\)$ ]]; then @@ -209,10 +210,6 @@ jobs: fi else # Triggered by workflow_dispatch - cd radius - COMMIT_MESSAGE=$(git log -1 --pretty=format:"%s" ${{ github.sha }}) - COMMIT_AUTHOR=$(git log -1 --pretty=format:"%an" ${{ github.sha }}) - echo "pr-title=Update auto-generated documentation (manual trigger)" >> $GITHUB_OUTPUT echo "pr-body<> $GITHUB_OUTPUT echo "## Autogenerated PR" >> $GITHUB_OUTPUT From d9a7fa1c1033ffbb700639c8b20d89aff0d960d1 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 3 Feb 2026 22:26:47 +0000 Subject: [PATCH 5/5] Improve comments to clarify SHA context and squash merge pattern Co-authored-by: willtsai <28876888+willtsai@users.noreply.github.com> --- .github/workflows/publish-docs.yaml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/publish-docs.yaml b/.github/workflows/publish-docs.yaml index 1094997111..89b23da53d 100644 --- a/.github/workflows/publish-docs.yaml +++ b/.github/workflows/publish-docs.yaml @@ -163,6 +163,7 @@ jobs: if: github.event_name == 'push' || (github.event_name == 'workflow_dispatch' && github.event.inputs.open_pull_request == 'true') run: | # Change to radius directory to extract commit information + # Note: ${{ github.sha }} refers to the triggering commit in the radius repository cd radius # Extract commit information @@ -172,8 +173,9 @@ jobs: # Determine the source of this workflow run if [[ "${{ github.event_name }}" == "push" ]]; then # Triggered by a push to main or release branch - # Check if this is a merge commit from a PR (GitHub creates merge commits with specific format) - # Format: "Merge pull request #123 from user/branch" or "Title (#123)" + # Check if this is a merge commit from a PR + # GitHub's squash merge format: "Title (#123)" - PR number at end of message + # This pattern specifically targets squash merges, which is the default for this repo if [[ "$COMMIT_MESSAGE" =~ \(#([0-9]+)\)$ ]]; then # Extract PR number from commit message PR_NUMBER="${BASH_REMATCH[1]}"