Skip to content

Commit ed5bf5f

Browse files
petesramekPete Sramekgithub-actions[bot]dependabot[bot]Copilot
authored
Fixed: lock/unlock missing admin token (#165)
Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: Pete Sramek <petr.sramek@dropoutcoder.com> Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Copilot <198982749+Copilot@users.noreply.github.com> Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
1 parent 6ddb19b commit ed5bf5f

4 files changed

Lines changed: 10 additions & 2 deletions

File tree

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,17 @@ inputs:
55
branch:
66
description: 'Branch name to lock.'
77
required: true
8+
token:
9+
description: 'GitHub token with administration:write (repo admin) permission. Use a PAT; GITHUB_TOKEN cannot call the branch protection API.'
10+
required: true
811

912
runs:
1013
using: composite
1114
steps:
1215
- name: 'Lock branch ${{ inputs.branch }}'
1316
shell: bash
1417
env:
15-
GH_TOKEN: ${{ github.token }}
18+
GH_TOKEN: ${{ inputs.token }}
1619
run: |
1720
if ! gh api --method PUT /repos/${{ github.repository }}/branches/${{ inputs.branch }}/protection \
1821
--input - << 'EOF'

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,17 @@ inputs:
55
branch:
66
description: 'Branch name to unlock.'
77
required: true
8+
token:
9+
description: 'GitHub token with administration:write (repo admin) permission. Use a PAT; GITHUB_TOKEN cannot call the branch protection API.'
10+
required: true
811

912
runs:
1013
using: composite
1114
steps:
1215
- name: 'Unlock branch ${{ inputs.branch }}'
1316
shell: bash
1417
env:
15-
GH_TOKEN: ${{ github.token }}
18+
GH_TOKEN: ${{ inputs.token }}
1619
run: |
1720
gh api --method DELETE /repos/${{ github.repository }}/branches/${{ inputs.branch }}/protection || true
1821
echo "🔓 Branch protection removed from '${{ inputs.branch }}'." >> $GITHUB_STEP_SUMMARY

.github/workflows/promote-branch.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,7 @@ jobs:
216216
uses: './.github/actions/github/branch-protection/lock'
217217
with:
218218
branch: ${{ needs.workflow-variables.outputs.target-branch }}
219+
token: ${{ secrets.GH_ADMIN_TOKEN }}
219220
- name: 'Create PR: "Promote ${{ env.current-branch }} to ${{ env.target-branch }}"'
220221
if: ${{ needs.workflow-variables.outputs.pull-request-exists == 'false' }}
221222
env:

.github/workflows/release.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -357,6 +357,7 @@ jobs:
357357
uses: './.github/actions/github/branch-protection/lock'
358358
with:
359359
branch: ${{ steps.resolve-support-branch.outputs.support-branch }}
360+
token: ${{ secrets.GH_ADMIN_TOKEN }}
360361

361362
- name: 'Write support branch summary'
362363
run: |

0 commit comments

Comments
 (0)