Skip to content

Commit ffa67f4

Browse files
Copilotpetesramek
andauthored
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>
1 parent fbffcd1 commit ffa67f4

2 files changed

Lines changed: 31 additions & 1 deletion

File tree

.github/actions/github/branch-protection/lock/action.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@ inputs:
88
token:
99
description: 'GitHub token with administration:write (repo admin) permission. Use a PAT; GITHUB_TOKEN cannot call the branch protection API.'
1010
required: true
11+
lock-branch:
12+
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.'
13+
required: false
14+
default: 'false'
1115

1216
runs:
1317
using: composite
@@ -30,7 +34,7 @@ runs:
3034
"restrictions": null,
3135
"allow_force_pushes": false,
3236
"allow_deletions": false,
33-
"lock_branch": false
37+
"lock_branch": ${{ inputs.lock-branch }}
3438
}
3539
EOF
3640
then

.github/workflows/backtrack.yml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,13 +61,23 @@ jobs:
6161
echo "::warning::Develop branch '${{ steps.targets.outputs.develop-branch }}' not found, skipping backtrack."
6262
fi
6363
64+
- name: 'Lock preview branch'
65+
id: lock-preview
66+
if: ${{ steps.targets.outputs.preview-branch != '' }}
67+
uses: './.github/actions/github/branch-protection/lock'
68+
with:
69+
branch: ${{ steps.targets.outputs.preview-branch }}
70+
token: ${{ secrets.GH_ADMIN_TOKEN }}
71+
lock-branch: 'true'
72+
6473
- name: 'Lock develop branch'
6574
id: lock-develop
6675
if: ${{ steps.check-develop.outputs.exists == 'true' }}
6776
uses: './.github/actions/github/branch-protection/lock'
6877
with:
6978
branch: ${{ steps.targets.outputs.develop-branch }}
7079
token: ${{ secrets.GH_ADMIN_TOKEN }}
80+
lock-branch: 'true'
7181

7282
- name: 'Backtrack: merge ${{ github.base_ref }} into ${{ steps.targets.outputs.preview-branch }}'
7383
if: ${{ steps.targets.outputs.preview-branch != '' }}
@@ -89,6 +99,22 @@ jobs:
8999
--field head="${{ steps.targets.outputs.merge-source }}" \
90100
--field commit_message="Backtrack: merge ${{ steps.targets.outputs.merge-source }} into ${{ steps.targets.outputs.develop-branch }}"
91101
102+
- name: 'Restore protection: preview branch'
103+
if: ${{ always() && steps.lock-preview.outcome == 'success' }}
104+
uses: './.github/actions/github/branch-protection/lock'
105+
with:
106+
branch: ${{ steps.targets.outputs.preview-branch }}
107+
token: ${{ secrets.GH_ADMIN_TOKEN }}
108+
lock-branch: 'false'
109+
110+
- name: 'Restore protection: develop branch'
111+
if: ${{ always() && steps.lock-develop.outcome == 'success' }}
112+
uses: './.github/actions/github/branch-protection/lock'
113+
with:
114+
branch: ${{ steps.targets.outputs.develop-branch }}
115+
token: ${{ secrets.GH_ADMIN_TOKEN }}
116+
lock-branch: 'false'
117+
92118
- name: 'Write backtrack summary'
93119
if: ${{ always() }}
94120
run: |

0 commit comments

Comments
 (0)