From bb78c06451c15d4c4aefddd97371098deb1ada15 Mon Sep 17 00:00:00 2001 From: sravani-revuri Date: Tue, 21 Jul 2026 16:13:47 +0530 Subject: [PATCH 1/2] HDDS-15922. Fix ozone-site config doc workflow reusing stale PR branch --- .../update-ozone-site-config-doc.yml | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) diff --git a/.github/workflows/update-ozone-site-config-doc.yml b/.github/workflows/update-ozone-site-config-doc.yml index 2fd61675cc7b..de6551c5faec 100644 --- a/.github/workflows/update-ozone-site-config-doc.yml +++ b/.github/workflows/update-ozone-site-config-doc.yml @@ -59,16 +59,8 @@ jobs: git config --global user.email 'github-actions[bot]@users.noreply.github.com' git clone --depth=1 --branch=master https://github.com/$REPO_OWNER/ozone-site.git ozone-site - - # Check if $BRANCH_NAME branch exists remotely cd ozone-site - if git ls-remote --heads origin $BRANCH_NAME | grep -q $BRANCH_NAME; then - echo "PR branch exists, checking it out for comparison" - git fetch --depth=1 origin $BRANCH_NAME - git checkout -B $BRANCH_NAME FETCH_HEAD - else - echo "PR branch does not exist, staying on master for comparison" - fi + echo "Using master as baseline for doc comparison and PR branch creation" - name: Check if documentation changed if: steps.check-site-repo.outputs.exists == 'true' @@ -131,12 +123,13 @@ jobs: run: | cd ozone-site - echo "Current branch: $(git branch --show-current)" - echo "Current commit: $(git rev-parse HEAD)" + echo "Baseline branch: master" + echo "Baseline commit: $(git rev-parse master)" - # Create/reset branch at current commit + # Always recreate the PR branch from master so merged changes are not replayed. + git checkout master git checkout -B "$BRANCH_NAME" - echo "Created/reset branch $BRANCH_NAME at current commit" + echo "Created branch $BRANCH_NAME from master" git add "$TARGET_FILE" From 7f9e900e3801578a35c0d0ebd4b387250ff44601 Mon Sep 17 00:00:00 2001 From: sravani-revuri Date: Thu, 23 Jul 2026 12:02:24 +0530 Subject: [PATCH 2/2] pr open logic included --- .../update-ozone-site-config-doc.yml | 57 ++++++++++++------- 1 file changed, 38 insertions(+), 19 deletions(-) diff --git a/.github/workflows/update-ozone-site-config-doc.yml b/.github/workflows/update-ozone-site-config-doc.yml index de6551c5faec..f60af3b77b67 100644 --- a/.github/workflows/update-ozone-site-config-doc.yml +++ b/.github/workflows/update-ozone-site-config-doc.yml @@ -53,6 +53,8 @@ jobs: - name: Checkout ozone-site repository if: steps.check-site-repo.outputs.exists == 'true' + env: + GH_TOKEN: ${{ secrets.OZONE_WEBSITE_BUILD }} run: | git config --global url."https://asf-ci-deploy:${{ secrets.OZONE_WEBSITE_BUILD }}@github.com/".insteadOf "https://github.com/" git config --global user.name 'github-actions[bot]' @@ -60,7 +62,17 @@ jobs: git clone --depth=1 --branch=master https://github.com/$REPO_OWNER/ozone-site.git ozone-site cd ozone-site - echo "Using master as baseline for doc comparison and PR branch creation" + + EXISTING_PR=$(gh pr list --repo "$REPO_OWNER/ozone-site" \ + --head "$BRANCH_NAME" --base master --json number --jq '.[0].number' || echo "") + + if [ -n "$EXISTING_PR" ]; then + echo "Open PR #$EXISTING_PR exists, checking out branch for comparison" + git fetch --depth=1 origin "$BRANCH_NAME" + git checkout -B "$BRANCH_NAME" FETCH_HEAD + else + echo "No open PR, using master as baseline for doc comparison" + fi - name: Check if documentation changed if: steps.check-site-repo.outputs.exists == 'true' @@ -120,30 +132,37 @@ jobs: - name: Commit and push changes if: steps.check-changes.outputs.changed == 'true' + env: + GH_TOKEN: ${{ secrets.OZONE_WEBSITE_BUILD }} run: | cd ozone-site - - echo "Baseline branch: master" - echo "Baseline commit: $(git rev-parse master)" - - # Always recreate the PR branch from master so merged changes are not replayed. - git checkout master - git checkout -B "$BRANCH_NAME" - echo "Created branch $BRANCH_NAME from master" - - git add "$TARGET_FILE" - - # Build commit message with JIRA ID if available + + EXISTING_PR=$(gh pr list --repo "$REPO_OWNER/ozone-site" \ + --head "$BRANCH_NAME" --base master --json number --jq '.[0].number' || echo "") + COMMIT_MSG="[Auto] Update configuration documentation from ozone $SHA" if [ -n "$JIRA_ID" ]; then COMMIT_MSG="$JIRA_ID. $COMMIT_MSG" fi - - git commit -m "$COMMIT_MSG" - - echo "Pushing $BRANCH_NAME to origin" - git push -f origin "$BRANCH_NAME" - + + if [ -n "$EXISTING_PR" ]; then + echo "Open PR #$EXISTING_PR exists, appending commit to preserve history" + git fetch --depth=1 origin "$BRANCH_NAME" + git checkout -B "$BRANCH_NAME" FETCH_HEAD + cp ../Configurations.md "$TARGET_FILE" + git add "$TARGET_FILE" + git commit -m "$COMMIT_MSG" + git push origin "$BRANCH_NAME" + else + echo "No open PR, recreating branch from master" + git checkout master + git checkout -B "$BRANCH_NAME" + cp ../Configurations.md "$TARGET_FILE" + git add "$TARGET_FILE" + git commit -m "$COMMIT_MSG" + git push -f origin "$BRANCH_NAME" + fi + - name: Create or update Pull Request in ozone-site if: steps.check-changes.outputs.changed == 'true' && github.repository == 'apache/ozone' env: