Skip to content

Update workflow to use Personal Access Token for PRs #4

Update workflow to use Personal Access Token for PRs

Update workflow to use Personal Access Token for PRs #4

name: Auto PR to Main
on:
push:
branches: [ develop ]
permissions:
contents: read
pull-requests: write
issues: write
jobs:
build-test-and-pr:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0 # Fetch all history for all branches
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: 9.0.x
- name: Restore dependencies
run: dotnet restore
- name: Build
run: dotnet build --no-restore --configuration Release
- name: Test
run: dotnet test --no-build --configuration Release --verbosity normal
- name: Create Pull Request
if: success()
run: |
# Create PR using GitHub REST API with PAT
curl -X POST \
-H "Authorization: token ${{ secrets.PAT_TOKEN }}" \
-H "Accept: application/vnd.github.v3+json" \
https://api.github.com/repos/${{ github.repository }}/pulls \
-d '{
"title": "Auto PR: Merge develop to main",
"body": "## Automated Pull Request\n\nThis PR was automatically created after successful CI build and tests on the develop branch.\n\n### What was validated:\n- Build successful\n- All tests passing\n- Code quality checks passed\n\n### Changes included:\nAll changes that were pushed to the develop branch since the last merge to main.\n\n### Review checklist:\n- [ ] Review code changes\n- [ ] Verify test coverage\n- [ ] Check for breaking changes\n- [ ] Update version if needed\n\nCreated automatically by GitHub Actions",
"head": "develop",
"base": "main"
}' || echo "PR creation failed - may already exist"