-
Notifications
You must be signed in to change notification settings - Fork 19
Description
Contact Details
No response
What happened?
build
GitHub Actions is not permitted to create or approve pull requests.
Reference:
https://github.com/itbackyard/CryptoNet/actions/runs/17153462150
Possible fix
You’ve hit an org/repo policy: “GitHub Actions is not permitted to create or approve pull requests.”
There are only two ways around it:
Option A — Change the repo setting (easiest)
If you’re an admin and policy allows it:
Settings → Actions → General → Workflow permissions
Set Workflow permissions to Read and write
Check: Allow GitHub Actions to create and approve pull requests
Then your current workflow with peter-evans/create-pull-request@v6 using GITHUB_TOKEN will work.
Option B — Use a personal/bot token (works even when the setting is disabled)
If you can’t enable that setting, use a PAT from a human/bot user with write access. The PAT acts as that user (not “GitHub Actions”), so it bypasses that restriction.
- Create the token
Create a fine-grained PAT on a bot/user account that has Write access to the repo:
Repository access: Only select repositories → choose your repo
Permissions (minimum):
Contents: Read & Write
Pull requests: Read & Write
Save it as a repo secret, e.g. CPR_TOKEN.
- Use it in your workflow
Drop-in, complete workflow (only difference is the token):
name: "3. Code Coverage"
permissions:
contents: write
pull-requests: write
on:
push:
branches:
- "main"
- "feature/*"
paths-ignore:
- "**/README.md"
- "coverage-badge.svg" # prevent loops after merge
pull_request:
branches:
- "main"
workflow_dispatch:
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
ref: ${{ github.ref }}
fetch-depth: 0
persist-credentials: false # we'll commit with the PAT via the action
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: 8.0.x
- name: Install ReportGenerator tool
run: dotnet tool install --global dotnet-reportgenerator-globaltool
- name: Restore dependencies
run: dotnet restore
- name: Build the solution
run: dotnet build --no-restore
- name: Run tests and collect code coverage
run: dotnet test --no-build --collect:"XPlat Code Coverage"
- name: Generate code coverage report
run: reportgenerator -reports:"**/coverage.cobertura.xml" -targetdir:"coverage" -reporttypes:"HtmlInline_AzurePipelines;Badges"
- name: Upload coverage report zip
uses: actions/upload-artifact@v4
with:
name: code-coverage-report
path: coverage
- name: Prepare badge for repo root (only on main)
if: github.ref == '
Version
3.0.x >= (Coming soon)
What Operating System are you seeing the problem on?
No response
Relevant log output
Code of Conduct
- I agree to follow this project's Code of Conduct