|
| 1 | +name: autofix-pr |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: |
| 6 | + - main |
| 7 | + |
| 8 | +concurrency: |
| 9 | + group: ${{ github.workflow }}-${{ github.ref }} |
| 10 | + cancel-in-progress: true |
| 11 | + |
| 12 | +permissions: |
| 13 | + contents: write |
| 14 | + pull-requests: write |
| 15 | + |
| 16 | +jobs: |
| 17 | + autofix-pr: |
| 18 | + name: "Auto-fix and create PR if needed" |
| 19 | + runs-on: ubuntu-latest |
| 20 | + steps: |
| 21 | + - uses: actions/checkout@v6 |
| 22 | + with: |
| 23 | + fetch-depth: 0 |
| 24 | + token: ${{ secrets.GHACTION_PAT }} |
| 25 | + |
| 26 | + - uses: actions/setup-python@v5 |
| 27 | + with: |
| 28 | + python-version: '>=3.10' |
| 29 | + |
| 30 | + - name: Run pre-commit |
| 31 | + id: precommit |
| 32 | + continue-on-error: true |
| 33 | + uses: pre-commit/action@v3.0.1 |
| 34 | + |
| 35 | + - name: Run author update script |
| 36 | + id: author-update |
| 37 | + continue-on-error: true |
| 38 | + run: | |
| 39 | + python3 buildbot/update_authors.py |
| 40 | +
|
| 41 | + - name: Check for changes |
| 42 | + id: check-changes |
| 43 | + run: | |
| 44 | + if [[ -n $(git status --porcelain) ]]; then |
| 45 | + echo "changes=true" >> $GITHUB_OUTPUT |
| 46 | + echo "Changes detected:" |
| 47 | + git status --short |
| 48 | + else |
| 49 | + echo "changes=false" >> $GITHUB_OUTPUT |
| 50 | + echo "No changes detected" |
| 51 | + fi |
| 52 | +
|
| 53 | + - name: Create Pull Request |
| 54 | + if: steps.check-changes.outputs.changes == 'true' |
| 55 | + uses: peter-evans/create-pull-request@v8 |
| 56 | + with: |
| 57 | + token: ${{ secrets.GHACTION_PAT }} |
| 58 | + commit-message: "[autofix] automatic fix after main branch workflow fail" |
| 59 | + branch: "actions/autofix" |
| 60 | + delete-branch: true |
| 61 | + title: "[autofix] automatic fix after main branch workflow fail" |
| 62 | + labels: | |
| 63 | + autofix.ci |
| 64 | + trigger-ci |
| 65 | + body: | |
| 66 | + ## Auto-generated fixes |
| 67 | +
|
| 68 | + This PR contains automatic fixes from pre-commit hooks and author updates. |
| 69 | +
|
| 70 | + **Triggered by**: ${{ github.event_name }} on `${{ github.ref_name }}` |
| 71 | + **Commit**: ${{ github.sha }} |
| 72 | +
|
| 73 | + ### Changes: |
| 74 | + - Pre-commit hook fixes |
| 75 | + - Author information updates |
| 76 | +
|
| 77 | + Please review the changes before merging. |
| 78 | +
|
| 79 | + - name: Summary |
| 80 | + if: always() |
| 81 | + run: | |
| 82 | + echo "## Autofix PR Workflow Summary" >> $GITHUB_STEP_SUMMARY |
| 83 | + echo "" >> $GITHUB_STEP_SUMMARY |
| 84 | + if [[ "${{ steps.check-changes.outputs.changes }}" == "true" ]]; then |
| 85 | + echo "✅ Changes detected and PR created" >> $GITHUB_STEP_SUMMARY |
| 86 | + else |
| 87 | + echo "✅ No changes needed" >> $GITHUB_STEP_SUMMARY |
| 88 | + fi |
0 commit comments