Skip to content

Merge pull request #25 from leeoades/copilot/secure-main-branch-settings #2

Merge pull request #25 from leeoades/copilot/secure-main-branch-settings

Merge pull request #25 from leeoades/copilot/secure-main-branch-settings #2

name: Apply Branch Protection

Check failure on line 1 in .github/workflows/branch-protection.yml

View workflow run for this annotation

GitHub Actions / .github/workflows/branch-protection.yml

Invalid workflow file

(Line: 11, Col: 3): Unexpected value 'administration'
on:
workflow_dispatch:
push:
branches: [main]
paths: ['.github/workflows/branch-protection.yml']
permissions:
contents: read
administration: write
jobs:
protect-main:
runs-on: ubuntu-latest
steps:
- name: Apply main branch protection rules
uses: actions/github-script@v7
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
await github.rest.repos.updateBranchProtection({
owner: context.repo.owner,
repo: context.repo.repo,
branch: 'main',
required_status_checks: null,
enforce_admins: true,
required_pull_request_reviews: {
required_approving_review_count: 1,
dismiss_stale_reviews: true,
require_code_owner_reviews: true,
},
restrictions: null,
allow_force_pushes: false,
allow_deletions: false,
});
console.log('Branch protection rules applied to main.');