Skip to content

Commit fbffcd1

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

1 file changed

Lines changed: 15 additions & 18 deletions

File tree

.github/workflows/backtrack.yml

Lines changed: 15 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -61,36 +61,33 @@ jobs:
6161
echo "::warning::Develop branch '${{ steps.targets.outputs.develop-branch }}' not found, skipping backtrack."
6262
fi
6363
64-
- name: 'Unlock develop branch'
65-
id: unlock-develop
64+
- name: 'Lock develop branch'
65+
id: lock-develop
6666
if: ${{ steps.check-develop.outputs.exists == 'true' }}
67-
uses: './.github/actions/github/branch-protection/unlock'
67+
uses: './.github/actions/github/branch-protection/lock'
6868
with:
6969
branch: ${{ steps.targets.outputs.develop-branch }}
7070
token: ${{ secrets.GH_ADMIN_TOKEN }}
7171

7272
- name: 'Backtrack: merge ${{ github.base_ref }} into ${{ steps.targets.outputs.preview-branch }}'
7373
if: ${{ steps.targets.outputs.preview-branch != '' }}
74+
env:
75+
GH_TOKEN: ${{ secrets.GH_ADMIN_TOKEN }}
7476
run: |
75-
git fetch origin
76-
git checkout -B ${{ steps.targets.outputs.preview-branch }} origin/${{ steps.targets.outputs.preview-branch }}
77-
git merge --no-ff origin/${{ github.base_ref }} -m "Backtrack: merge ${{ github.base_ref }} into ${{ steps.targets.outputs.preview-branch }}"
78-
git push origin ${{ steps.targets.outputs.preview-branch }}
77+
gh api --method POST /repos/${{ github.repository }}/merges \
78+
--field base="${{ steps.targets.outputs.preview-branch }}" \
79+
--field head="${{ github.base_ref }}" \
80+
--field commit_message="Backtrack: merge ${{ github.base_ref }} into ${{ steps.targets.outputs.preview-branch }}"
7981
8082
- name: 'Backtrack: merge ${{ steps.targets.outputs.merge-source }} into ${{ steps.targets.outputs.develop-branch }}'
8183
if: ${{ steps.check-develop.outputs.exists == 'true' }}
84+
env:
85+
GH_TOKEN: ${{ secrets.GH_ADMIN_TOKEN }}
8286
run: |
83-
git fetch origin
84-
git checkout -B ${{ steps.targets.outputs.develop-branch }} origin/${{ steps.targets.outputs.develop-branch }}
85-
git merge --no-ff origin/${{ steps.targets.outputs.merge-source }} -m "Backtrack: merge ${{ steps.targets.outputs.merge-source }} into ${{ steps.targets.outputs.develop-branch }}"
86-
git push origin ${{ steps.targets.outputs.develop-branch }}
87-
88-
- name: 'Lock develop branch'
89-
if: ${{ always() && steps.unlock-develop.outcome != 'skipped' }}
90-
uses: './.github/actions/github/branch-protection/lock'
91-
with:
92-
branch: ${{ steps.targets.outputs.develop-branch }}
93-
token: ${{ secrets.GH_ADMIN_TOKEN }}
87+
gh api --method POST /repos/${{ github.repository }}/merges \
88+
--field base="${{ steps.targets.outputs.develop-branch }}" \
89+
--field head="${{ steps.targets.outputs.merge-source }}" \
90+
--field commit_message="Backtrack: merge ${{ steps.targets.outputs.merge-source }} into ${{ steps.targets.outputs.develop-branch }}"
9491
9592
- name: 'Write backtrack summary'
9693
if: ${{ always() }}

0 commit comments

Comments
 (0)