self-mutation #204
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
| # ~~ Generated by projen. To modify, edit .projenrc.ts and run "npx projen". | |
| name: self-mutation | |
| on: | |
| workflow_run: | |
| workflows: | |
| - build | |
| types: | |
| - completed | |
| jobs: | |
| self-mutation: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| environment: automation | |
| if: github.event.workflow_run.conclusion == 'failure' && github.event.workflow_run.event == 'pull_request' | |
| steps: | |
| - name: Download patch | |
| id: download_patch | |
| uses: dawidd6/action-download-artifact@ac66b43f0e6a346234dd65d4d0c8fbb31cb316e5 | |
| with: | |
| run_id: ${{ github.event.workflow_run.id }} | |
| name: repo.patch | |
| path: ${{ runner.temp }} | |
| continue-on-error: true | |
| - name: Generate token | |
| id: generate_token | |
| if: steps.download_patch.outcome == 'success' | |
| uses: actions/create-github-app-token@3ff1caaa28b64c9cc276ce0a02e2ff584f3900c5 | |
| with: | |
| app-id: ${{ secrets.PROJEN_APP_ID }} | |
| private-key: ${{ secrets.PROJEN_APP_PRIVATE_KEY }} | |
| - name: Checkout PR | |
| if: steps.download_patch.outcome == 'success' | |
| uses: actions/checkout@v5 | |
| with: | |
| token: ${{ steps.generate_token.outputs.token }} | |
| ref: ${{ github.event.workflow_run.head_branch }} | |
| repository: ${{ github.event.workflow_run.head_repository.full_name }} | |
| - name: Apply patch to PR | |
| if: steps.download_patch.outcome == 'success' | |
| run: |- | |
| set -e | |
| if [ ! -f "${{ runner.temp }}/repo.patch" ]; then | |
| echo "Patch file not found" | |
| exit 1 | |
| fi | |
| git config user.name "github-actions[bot]" | |
| git config user.email "github-actions[bot]@users.noreply.github.com" | |
| if ! git apply --check ${{ runner.temp }}/repo.patch; then | |
| echo "Patch cannot be applied cleanly" | |
| exit 1 | |
| fi | |
| git apply ${{ runner.temp }}/repo.patch | |
| if [ -z "$(git status --porcelain)" ]; then | |
| echo "No changes to commit" | |
| exit 0 | |
| fi | |
| git add . | |
| git commit -s -m "chore: self mutation" | |
| git push |