Update workflow permissions and PR creation steps #2
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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() | |
| env: | |
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| run: | | |
| gh pr create \ | |
| --base main \ | |
| --head develop \ | |
| --title "Auto PR: Merge develop to main" \ | |
| --body "## Automated Pull Request | |
| This PR was automatically created after successful CI build and tests on the develop branch. | |
| ### What was validated: | |
| - Build successful | |
| - All tests passing | |
| - Code quality checks passed | |
| ### Changes included: | |
| All changes that were pushed to the develop branch since the last merge to main. | |
| ### Review checklist: | |
| - [ ] Review code changes | |
| - [ ] Verify test coverage | |
| - [ ] Check for breaking changes | |
| - [ ] Update version if needed | |
| Created automatically by GitHub Actions" \ | |
| --label "automated" \ | |
| --label "ci-cd" \ | |
| --label "ready-for-review" 2>/dev/null || { | |
| echo "Failed to create PR - it may already exist" | |
| exit 0 | |
| } |