ci: avoid unnecessary label removal/re-adding on PR edits (#6479) #7687
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: Code Style | |
| on: | |
| push: | |
| branches: [temp] | |
| pull_request: | |
| types: [opened, synchronize, reopened, ready_for_review] | |
| repository_dispatch: | |
| types: [code-style-command] # triggered by /code-style PR comment | |
| env: | |
| writable: ${{ (github.event_name == 'repository_dispatch' || github.ref == 'refs/heads/temp' || github.event.pull_request.head.repo.full_name == github.repository && github.actor != 'dependabot[bot]') && 1 || 0 }} | |
| permissions: | |
| contents: read | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} | |
| cancel-in-progress: true | |
| jobs: | |
| php-cs-fixer: | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 30 | |
| if: github.event.pull_request.draft == false | |
| permissions: | |
| contents: write # for stefanzweifel/git-auto-commit-action to push code in repo | |
| steps: | |
| - name: Add action run link to trigger comment | |
| uses: peter-evans/create-or-update-comment@e8674b075228eee787fea43ef493e45ece1004c9 # v5.0.0 | |
| if: github.event_name == 'repository_dispatch' | |
| with: | |
| token: ${{ secrets.BOT_TOKEN }} | |
| repository: ${{ github.event.client_payload.github.payload.repository.full_name }} | |
| comment-id: ${{ github.event.client_payload.github.payload.comment.id }} | |
| body: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }} | |
| - name: Checkout | |
| uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 | |
| if: env.writable == 1 && github.event_name != 'repository_dispatch' | |
| with: | |
| ref: ${{ github.head_ref }} | |
| token: ${{ secrets.BOT_TOKEN }} | |
| - name: Checkout fork | |
| uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 | |
| if: env.writable == 0 | |
| - name: Checkout on chat command | |
| uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 | |
| if: github.event_name == 'repository_dispatch' | |
| with: | |
| token: ${{ secrets.BOT_TOKEN }} | |
| repository: ${{ github.event.client_payload.pull_request.head.repo.full_name }} | |
| ref: ${{ github.event.client_payload.pull_request.head.ref }} | |
| - name: Setup PHP | |
| uses: shivammathur/setup-php@accd6127cb78bee3e8082180cb391013d204ef9f # 2.37.0 | |
| with: | |
| php-version: '8.3' | |
| coverage: none # disable xdebug, pcov | |
| tools: cs2pr | |
| - name: Composer install | |
| uses: ramsey/composer-install@65e4f84970763564f46a70b8a54b90d033b3bdda # 4.0.0 | |
| - name: Fix code style | |
| if: env.writable == 1 | |
| run: vendor/bin/php-cs-fixer list-files --config=.php-cs-fixer.dist.php | xargs -n 250 -P 3 vendor/bin/php-cs-fixer fix --diff --config=.php-cs-fixer.dist.php | |
| - name: Commit changed files | |
| uses: stefanzweifel/git-auto-commit-action@04702edda442b2e678b25b537cec683a1493fcb9 # v7.1.0 | |
| if: env.writable == 1 | |
| with: | |
| commit_message: 'style: apply php-cs-fixer changes' | |
| commit_user_name: rex-bot | |
| commit_user_email: rex-bot@users.noreply.github.com | |
| branch: ${{ github.head_ref }} # repo dispatch needs the target branch | |
| - name: Check code style | |
| if: env.writable == 0 | |
| run: vendor/bin/php-cs-fixer fix --ansi --diff --dry-run --format=checkstyle | cs2pr # check whether there are still errors left | |
| rector: | |
| permissions: | |
| contents: write # for stefanzweifel/git-auto-commit-action to push code in repo | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 30 | |
| if: github.event.pull_request.draft == false && github.event_name != 'repository_dispatch' | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 | |
| if: env.writable == 1 | |
| with: | |
| ref: ${{ github.head_ref }} | |
| token: ${{ secrets.BOT_TOKEN }} | |
| - name: Checkout fork | |
| uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 | |
| if: env.writable == 0 | |
| - name: Setup PHP | |
| uses: shivammathur/setup-php@accd6127cb78bee3e8082180cb391013d204ef9f # 2.37.0 | |
| with: | |
| php-version: '8.3' | |
| coverage: none # disable xdebug, pcov | |
| - name: Composer install | |
| uses: ramsey/composer-install@65e4f84970763564f46a70b8a54b90d033b3bdda # 4.0.0 | |
| - name: Fix code style | |
| if: env.writable == 1 | |
| run: vendor/bin/rector process --no-progress-bar | |
| - name: Commit changed files | |
| uses: stefanzweifel/git-auto-commit-action@04702edda442b2e678b25b537cec683a1493fcb9 # v7.1.0 | |
| if: env.writable == 1 | |
| with: | |
| commit_message: 'refactor: apply rector changes' | |
| commit_user_name: rex-bot | |
| commit_user_email: rex-bot@users.noreply.github.com | |
| - name: Check code style | |
| run: vendor/bin/rector process --ansi --no-progress-bar --dry-run |