From f33bc0ec93e6d3d2b547021b50aabce83a43a918 Mon Sep 17 00:00:00 2001 From: etserend Date: Mon, 27 Jul 2026 15:07:01 -0500 Subject: [PATCH 1/4] fix(ci): prevent duplicate PRs in publish-docs workflow Use a static branch name instead of run_id-suffixed branches so re-runs update the existing PR via force-push rather than opening new ones. Co-Authored-By: Claude Opus 4.7 --- .github/workflows/publish-docs.yaml | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/.github/workflows/publish-docs.yaml b/.github/workflows/publish-docs.yaml index d12f2289..3100ed8d 100644 --- a/.github/workflows/publish-docs.yaml +++ b/.github/workflows/publish-docs.yaml @@ -49,7 +49,8 @@ jobs: - name: Create a branch working-directory: ./splunk-ao-docs - run: git checkout -b feat/update-docs-${GITHUB_REF_NAME}-${{ github.run_id }} + run: | + git fetch origin feat/update-docs-${GITHUB_REF_NAME} 2>/dev/null && git checkout feat/update-docs-${GITHUB_REF_NAME} || git checkout -b feat/update-docs-${GITHUB_REF_NAME} - name: Update SDK docs run: | @@ -73,8 +74,8 @@ jobs: exit 0 fi echo "has_changes=true" >> "$GITHUB_OUTPUT" - git commit -m "Updating docs from ${GITHUB_REF_NAME}-${{ github.run_id }}" - git push -u origin feat/update-docs-${GITHUB_REF_NAME}-${{ github.run_id }} + git commit -m "Updating docs from ${GITHUB_REF_NAME}" + git push origin feat/update-docs-${GITHUB_REF_NAME} --force - name: Create PR if: steps.commit.outputs.has_changes == 'true' @@ -97,4 +98,10 @@ jobs: **DO NOT** approve this PR until you have completed these checks. run: | - gh pr create --title "Updated Python SDK docs" --body "$PR_BODY" + BRANCH_NAME=feat/update-docs-${GITHUB_REF_NAME} + EXISTING_PR=$(gh pr list --base main --head $BRANCH_NAME --state open --json number --jq '.[0].number') + if [ -n "$EXISTING_PR" ]; then + echo "PR #$EXISTING_PR already open for branch $BRANCH_NAME — updated via force push" + else + gh pr create --title "Updated Python SDK docs" --body "$PR_BODY" + fi From fde008dba50d5b87832e3a4a9f64d63370eaf0ec Mon Sep 17 00:00:00 2001 From: etserend Date: Mon, 27 Jul 2026 16:14:36 -0500 Subject: [PATCH 2/4] fix(ci): always push and update PR on every publish-docs run Use --allow-empty so every run force-pushes to the static branch and the "Create PR" step always runs, keeping the PR's last-updated time current regardless of whether docs content changed. Co-Authored-By: Claude Opus 4.7 --- .github/workflows/publish-docs.yaml | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/.github/workflows/publish-docs.yaml b/.github/workflows/publish-docs.yaml index 3100ed8d..a482a0e2 100644 --- a/.github/workflows/publish-docs.yaml +++ b/.github/workflows/publish-docs.yaml @@ -59,7 +59,6 @@ jobs: cp -r ./splunk-ao-python/.generated_docs/reference ./splunk-ao-docs/sdk-api/python/ - name: Commit changes - id: commit working-directory: ./splunk-ao-docs env: PAT: ${{ secrets.PAT_AO_DOC_AUTOMATION }} @@ -68,17 +67,10 @@ jobs: git config --global user.name "github-actions[bot]" git remote set-url origin https://x-access-token:${PAT}@github.com/splunk/agent-observability-docs.git git add . - if git diff --cached --quiet; then - echo "No doc changes to publish" - echo "has_changes=false" >> "$GITHUB_OUTPUT" - exit 0 - fi - echo "has_changes=true" >> "$GITHUB_OUTPUT" - git commit -m "Updating docs from ${GITHUB_REF_NAME}" + git commit --allow-empty -m "Updating docs from ${GITHUB_REF_NAME}" git push origin feat/update-docs-${GITHUB_REF_NAME} --force - name: Create PR - if: steps.commit.outputs.has_changes == 'true' working-directory: ./splunk-ao-docs env: GH_TOKEN: ${{ secrets.PAT_AO_DOC_AUTOMATION }} From f417ae51f347d525fd93e444b36580663b4236f8 Mon Sep 17 00:00:00 2001 From: etserend Date: Tue, 28 Jul 2026 11:54:45 -0500 Subject: [PATCH 3/4] fix(ci): address reviewer feedback on publish-docs workflow - Add -B main -H $BRANCH_NAME to gh pr create so base branch is explicit and consistent with the --head filter in pr list - Drop --base main from gh pr list to avoid silent dedup failure if docs repo default branch ever changes - Vary commit message (no-change vs actual update) to reduce noise in docs repo history Co-Authored-By: Claude Opus 4.7 --- .github/workflows/publish-docs.yaml | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/.github/workflows/publish-docs.yaml b/.github/workflows/publish-docs.yaml index a482a0e2..a5f077f7 100644 --- a/.github/workflows/publish-docs.yaml +++ b/.github/workflows/publish-docs.yaml @@ -67,7 +67,12 @@ jobs: git config --global user.name "github-actions[bot]" git remote set-url origin https://x-access-token:${PAT}@github.com/splunk/agent-observability-docs.git git add . - git commit --allow-empty -m "Updating docs from ${GITHUB_REF_NAME}" + if git diff --cached --quiet; then + COMMIT_MSG="No doc changes — run refresh from ${GITHUB_REF_NAME}" + else + COMMIT_MSG="Updating docs from ${GITHUB_REF_NAME}" + fi + git commit --allow-empty -m "$COMMIT_MSG" git push origin feat/update-docs-${GITHUB_REF_NAME} --force - name: Create PR @@ -91,9 +96,9 @@ jobs: **DO NOT** approve this PR until you have completed these checks. run: | BRANCH_NAME=feat/update-docs-${GITHUB_REF_NAME} - EXISTING_PR=$(gh pr list --base main --head $BRANCH_NAME --state open --json number --jq '.[0].number') + EXISTING_PR=$(gh pr list --head $BRANCH_NAME --state open --json number --jq '.[0].number') if [ -n "$EXISTING_PR" ]; then echo "PR #$EXISTING_PR already open for branch $BRANCH_NAME — updated via force push" else - gh pr create --title "Updated Python SDK docs" --body "$PR_BODY" + gh pr create -B main -H $BRANCH_NAME --title "Updated Python SDK docs" --body "$PR_BODY" fi From 758babade24120f22938a3951b4b3e27cd2a5ff1 Mon Sep 17 00:00:00 2001 From: etserend Date: Wed, 29 Jul 2026 12:34:04 -0500 Subject: [PATCH 4/4] fix(ci): address review feedback on publish-docs workflow MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Branch reuse: use `git checkout -B ... FETCH_HEAD` so the existing remote branch is reliably checked out after a shallow fetch (fixes silent fallback to a fresh branch that could wipe reviewer commits) - No-op guard: restore has_changes check; only commit/push/create PR when docs actually changed — empty-commit noise eliminated - Quote $BRANCH_NAME in gh pr list/create to satisfy shellcheck SC2086 Co-Authored-By: Claude Opus 4.7 --- .github/workflows/publish-docs.yaml | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/.github/workflows/publish-docs.yaml b/.github/workflows/publish-docs.yaml index a5f077f7..e7f28c54 100644 --- a/.github/workflows/publish-docs.yaml +++ b/.github/workflows/publish-docs.yaml @@ -50,7 +50,7 @@ jobs: - name: Create a branch working-directory: ./splunk-ao-docs run: | - git fetch origin feat/update-docs-${GITHUB_REF_NAME} 2>/dev/null && git checkout feat/update-docs-${GITHUB_REF_NAME} || git checkout -b feat/update-docs-${GITHUB_REF_NAME} + git fetch origin feat/update-docs-${GITHUB_REF_NAME} 2>/dev/null && git checkout -B feat/update-docs-${GITHUB_REF_NAME} FETCH_HEAD || git checkout -b feat/update-docs-${GITHUB_REF_NAME} - name: Update SDK docs run: | @@ -59,6 +59,7 @@ jobs: cp -r ./splunk-ao-python/.generated_docs/reference ./splunk-ao-docs/sdk-api/python/ - name: Commit changes + id: commit working-directory: ./splunk-ao-docs env: PAT: ${{ secrets.PAT_AO_DOC_AUTOMATION }} @@ -68,14 +69,15 @@ jobs: git remote set-url origin https://x-access-token:${PAT}@github.com/splunk/agent-observability-docs.git git add . if git diff --cached --quiet; then - COMMIT_MSG="No doc changes — run refresh from ${GITHUB_REF_NAME}" + echo "has_changes=false" >> "$GITHUB_OUTPUT" else - COMMIT_MSG="Updating docs from ${GITHUB_REF_NAME}" + git commit -m "Updating docs from ${GITHUB_REF_NAME}" + git push origin feat/update-docs-${GITHUB_REF_NAME} --force + echo "has_changes=true" >> "$GITHUB_OUTPUT" fi - git commit --allow-empty -m "$COMMIT_MSG" - git push origin feat/update-docs-${GITHUB_REF_NAME} --force - name: Create PR + if: steps.commit.outputs.has_changes == 'true' working-directory: ./splunk-ao-docs env: GH_TOKEN: ${{ secrets.PAT_AO_DOC_AUTOMATION }} @@ -96,9 +98,9 @@ jobs: **DO NOT** approve this PR until you have completed these checks. run: | BRANCH_NAME=feat/update-docs-${GITHUB_REF_NAME} - EXISTING_PR=$(gh pr list --head $BRANCH_NAME --state open --json number --jq '.[0].number') + EXISTING_PR=$(gh pr list --head "$BRANCH_NAME" --state open --json number --jq '.[0].number') if [ -n "$EXISTING_PR" ]; then echo "PR #$EXISTING_PR already open for branch $BRANCH_NAME — updated via force push" else - gh pr create -B main -H $BRANCH_NAME --title "Updated Python SDK docs" --body "$PR_BODY" + gh pr create -B main -H "$BRANCH_NAME" --title "Updated Python SDK docs" --body "$PR_BODY" fi