From c36a9c82c375ac01477f7d357a530f1c12fee625 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sat, 4 Apr 2026 12:27:36 +0000 Subject: [PATCH 1/4] fix: swap lock/unlock order in backtrack workflow Agent-Logs-Url: https://github.com/petesramek/polyline-algorithm-csharp/sessions/46a3d0dc-cb13-4a78-bcfd-c6565b325c31 Co-authored-by: petesramek <2333452+petesramek@users.noreply.github.com> --- .github/workflows/backtrack.yml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/backtrack.yml b/.github/workflows/backtrack.yml index ef6355ce..48c4b317 100644 --- a/.github/workflows/backtrack.yml +++ b/.github/workflows/backtrack.yml @@ -61,10 +61,10 @@ jobs: echo "::warning::Develop branch '${{ steps.targets.outputs.develop-branch }}' not found, skipping backtrack." fi - - name: 'Lock develop branch' - id: lock-develop + - name: 'Unlock develop branch' + id: unlock-develop if: ${{ steps.check-develop.outputs.exists == 'true' }} - uses: './.github/actions/github/branch-protection/lock' + uses: './.github/actions/github/branch-protection/unlock' with: branch: ${{ steps.targets.outputs.develop-branch }} token: ${{ secrets.GH_ADMIN_TOKEN }} @@ -85,9 +85,9 @@ jobs: git merge --no-ff origin/${{ steps.targets.outputs.merge-source }} -m "Backtrack: merge ${{ steps.targets.outputs.merge-source }} into ${{ steps.targets.outputs.develop-branch }}" git push origin ${{ steps.targets.outputs.develop-branch }} - - name: 'Unlock develop branch' - if: ${{ always() && steps.lock-develop.outcome != 'skipped' }} - uses: './.github/actions/github/branch-protection/unlock' + - name: 'Lock develop branch' + if: ${{ always() && steps.unlock-develop.outcome != 'skipped' }} + uses: './.github/actions/github/branch-protection/lock' with: branch: ${{ steps.targets.outputs.develop-branch }} token: ${{ secrets.GH_ADMIN_TOKEN }} From fbffcd15b8f2a9e93b0c539272384ad8432a7b04 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sat, 4 Apr 2026 12:34:28 +0000 Subject: [PATCH 2/4] fix: lock branch during backtrack, use REST API merge to bypass git push 403 Agent-Logs-Url: https://github.com/petesramek/polyline-algorithm-csharp/sessions/0bdd21ff-4b77-41fb-9a82-83016fb91c1c Co-authored-by: petesramek <2333452+petesramek@users.noreply.github.com> --- .github/workflows/backtrack.yml | 33 +++++++++++++++------------------ 1 file changed, 15 insertions(+), 18 deletions(-) diff --git a/.github/workflows/backtrack.yml b/.github/workflows/backtrack.yml index 48c4b317..15e9acaa 100644 --- a/.github/workflows/backtrack.yml +++ b/.github/workflows/backtrack.yml @@ -61,36 +61,33 @@ jobs: echo "::warning::Develop branch '${{ steps.targets.outputs.develop-branch }}' not found, skipping backtrack." fi - - name: 'Unlock develop branch' - id: unlock-develop + - name: 'Lock develop branch' + id: lock-develop if: ${{ steps.check-develop.outputs.exists == 'true' }} - uses: './.github/actions/github/branch-protection/unlock' + uses: './.github/actions/github/branch-protection/lock' with: branch: ${{ steps.targets.outputs.develop-branch }} token: ${{ secrets.GH_ADMIN_TOKEN }} - name: 'Backtrack: merge ${{ github.base_ref }} into ${{ steps.targets.outputs.preview-branch }}' if: ${{ steps.targets.outputs.preview-branch != '' }} + env: + GH_TOKEN: ${{ secrets.GH_ADMIN_TOKEN }} run: | - git fetch origin - git checkout -B ${{ steps.targets.outputs.preview-branch }} origin/${{ steps.targets.outputs.preview-branch }} - git merge --no-ff origin/${{ github.base_ref }} -m "Backtrack: merge ${{ github.base_ref }} into ${{ steps.targets.outputs.preview-branch }}" - git push origin ${{ steps.targets.outputs.preview-branch }} + gh api --method POST /repos/${{ github.repository }}/merges \ + --field base="${{ steps.targets.outputs.preview-branch }}" \ + --field head="${{ github.base_ref }}" \ + --field commit_message="Backtrack: merge ${{ github.base_ref }} into ${{ steps.targets.outputs.preview-branch }}" - name: 'Backtrack: merge ${{ steps.targets.outputs.merge-source }} into ${{ steps.targets.outputs.develop-branch }}' if: ${{ steps.check-develop.outputs.exists == 'true' }} + env: + GH_TOKEN: ${{ secrets.GH_ADMIN_TOKEN }} run: | - git fetch origin - git checkout -B ${{ steps.targets.outputs.develop-branch }} origin/${{ steps.targets.outputs.develop-branch }} - git merge --no-ff origin/${{ steps.targets.outputs.merge-source }} -m "Backtrack: merge ${{ steps.targets.outputs.merge-source }} into ${{ steps.targets.outputs.develop-branch }}" - git push origin ${{ steps.targets.outputs.develop-branch }} - - - name: 'Lock develop branch' - if: ${{ always() && steps.unlock-develop.outcome != 'skipped' }} - uses: './.github/actions/github/branch-protection/lock' - with: - branch: ${{ steps.targets.outputs.develop-branch }} - token: ${{ secrets.GH_ADMIN_TOKEN }} + gh api --method POST /repos/${{ github.repository }}/merges \ + --field base="${{ steps.targets.outputs.develop-branch }}" \ + --field head="${{ steps.targets.outputs.merge-source }}" \ + --field commit_message="Backtrack: merge ${{ steps.targets.outputs.merge-source }} into ${{ steps.targets.outputs.develop-branch }}" - name: 'Write backtrack summary' if: ${{ always() }} From ffa67f426273860baaffcc909d52ca1db3977858 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sat, 4 Apr 2026 12:38:57 +0000 Subject: [PATCH 3/4] fix(backtrack): lock both branches during backtrack, restore permanent protection after Agent-Logs-Url: https://github.com/petesramek/polyline-algorithm-csharp/sessions/1b29c883-dc1f-40a8-8c17-6a3cef7ef9f4 Co-authored-by: petesramek <2333452+petesramek@users.noreply.github.com> --- .../github/branch-protection/lock/action.yml | 6 ++++- .github/workflows/backtrack.yml | 26 +++++++++++++++++++ 2 files changed, 31 insertions(+), 1 deletion(-) diff --git a/.github/actions/github/branch-protection/lock/action.yml b/.github/actions/github/branch-protection/lock/action.yml index d8f345a1..fa7a96e1 100644 --- a/.github/actions/github/branch-protection/lock/action.yml +++ b/.github/actions/github/branch-protection/lock/action.yml @@ -8,6 +8,10 @@ inputs: token: description: 'GitHub token with administration:write (repo admin) permission. Use a PAT; GITHUB_TOKEN cannot call the branch protection API.' required: true + lock-branch: + description: 'When true, sets lock_branch to prevent even PR merges (use during automated operations). When false (default), only direct pushes are blocked; PRs with required reviews can still be merged.' + required: false + default: 'false' runs: using: composite @@ -30,7 +34,7 @@ runs: "restrictions": null, "allow_force_pushes": false, "allow_deletions": false, - "lock_branch": false + "lock_branch": ${{ inputs.lock-branch }} } EOF then diff --git a/.github/workflows/backtrack.yml b/.github/workflows/backtrack.yml index 15e9acaa..c4880925 100644 --- a/.github/workflows/backtrack.yml +++ b/.github/workflows/backtrack.yml @@ -61,6 +61,15 @@ jobs: echo "::warning::Develop branch '${{ steps.targets.outputs.develop-branch }}' not found, skipping backtrack." fi + - name: 'Lock preview branch' + id: lock-preview + if: ${{ steps.targets.outputs.preview-branch != '' }} + uses: './.github/actions/github/branch-protection/lock' + with: + branch: ${{ steps.targets.outputs.preview-branch }} + token: ${{ secrets.GH_ADMIN_TOKEN }} + lock-branch: 'true' + - name: 'Lock develop branch' id: lock-develop if: ${{ steps.check-develop.outputs.exists == 'true' }} @@ -68,6 +77,7 @@ jobs: with: branch: ${{ steps.targets.outputs.develop-branch }} token: ${{ secrets.GH_ADMIN_TOKEN }} + lock-branch: 'true' - name: 'Backtrack: merge ${{ github.base_ref }} into ${{ steps.targets.outputs.preview-branch }}' if: ${{ steps.targets.outputs.preview-branch != '' }} @@ -89,6 +99,22 @@ jobs: --field head="${{ steps.targets.outputs.merge-source }}" \ --field commit_message="Backtrack: merge ${{ steps.targets.outputs.merge-source }} into ${{ steps.targets.outputs.develop-branch }}" + - name: 'Restore protection: preview branch' + if: ${{ always() && steps.lock-preview.outcome == 'success' }} + uses: './.github/actions/github/branch-protection/lock' + with: + branch: ${{ steps.targets.outputs.preview-branch }} + token: ${{ secrets.GH_ADMIN_TOKEN }} + lock-branch: 'false' + + - name: 'Restore protection: develop branch' + if: ${{ always() && steps.lock-develop.outcome == 'success' }} + uses: './.github/actions/github/branch-protection/lock' + with: + branch: ${{ steps.targets.outputs.develop-branch }} + token: ${{ secrets.GH_ADMIN_TOKEN }} + lock-branch: 'false' + - name: 'Write backtrack summary' if: ${{ always() }} run: | From 4f8608b0d8a20518a2efca681e44abf7f78b4775 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sat, 4 Apr 2026 12:47:40 +0000 Subject: [PATCH 4/4] fix(backtrack): lock base branch during backtrack to prevent concurrent PR merges Agent-Logs-Url: https://github.com/petesramek/polyline-algorithm-csharp/sessions/54b5571e-b301-4ccb-b952-73582ebbd9a4 Co-authored-by: petesramek <2333452+petesramek@users.noreply.github.com> --- .github/workflows/backtrack.yml | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/.github/workflows/backtrack.yml b/.github/workflows/backtrack.yml index c4880925..e15e1273 100644 --- a/.github/workflows/backtrack.yml +++ b/.github/workflows/backtrack.yml @@ -61,6 +61,14 @@ jobs: echo "::warning::Develop branch '${{ steps.targets.outputs.develop-branch }}' not found, skipping backtrack." fi + - name: 'Lock base branch' + id: lock-base + uses: './.github/actions/github/branch-protection/lock' + with: + branch: ${{ github.base_ref }} + token: ${{ secrets.GH_ADMIN_TOKEN }} + lock-branch: 'true' + - name: 'Lock preview branch' id: lock-preview if: ${{ steps.targets.outputs.preview-branch != '' }} @@ -99,6 +107,14 @@ jobs: --field head="${{ steps.targets.outputs.merge-source }}" \ --field commit_message="Backtrack: merge ${{ steps.targets.outputs.merge-source }} into ${{ steps.targets.outputs.develop-branch }}" + - name: 'Restore protection: base branch' + if: ${{ always() && steps.lock-base.outcome == 'success' }} + uses: './.github/actions/github/branch-protection/lock' + with: + branch: ${{ github.base_ref }} + token: ${{ secrets.GH_ADMIN_TOKEN }} + lock-branch: 'false' + - name: 'Restore protection: preview branch' if: ${{ always() && steps.lock-preview.outcome == 'success' }} uses: './.github/actions/github/branch-protection/lock'