-
-
Notifications
You must be signed in to change notification settings - Fork 63
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[BUGFIX] Fix rector in ci for pull requests
- Loading branch information
1 parent
ea6323b
commit 5cd38e6
Showing
1 changed file
with
21 additions
and
53 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,78 +1,46 @@ | ||
#### | ||
# Due to some Github Actions limitations, we are running realtime fixes (commits) only for self-owned-pr | ||
# | ||
# Current limitations: | ||
# - Secrets (ACCESS_TOKEN) are not available in PRs from forks | ||
# - Github Token has Read-only access (can not commit), Personal Access Token must be used instead | ||
# - Github Token does not trigger workflows after push | ||
# | ||
# So we basically have chicken-egg problem here | ||
# | ||
# https://help.github.com/en/actions/configuring-and-managing-workflows/authenticating-with-the-github_token#permissions-for-the-github_token | ||
#### | ||
name: Rector | ||
|
||
on: | ||
pull_request: null | ||
|
||
env: | ||
# see https://github.com/composer/composer/issues/9368#issuecomment-718112361 | ||
COMPOSER_ROOT_VERSION: "dev-main" | ||
|
||
jobs: | ||
rector: | ||
# Don't run on forks. | ||
if: github.repository == 'sabbelasichon/typo3-rector' | ||
timeout-minutes: 10 | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
paths: | ||
- src tests | ||
- config utils | ||
|
||
runs-on: ubuntu-latest | ||
timeout-minutes: 8 | ||
|
||
if: github.event.pull_request.head.repo.full_name == 'sabbelasichon/typo3-rector' | ||
steps: | ||
# workaround for missing secret in fork PRs - see https://github.com/actions/checkout/issues/298 | ||
# see https://github.com/rectorphp/rector/commit/d395e1c28b8e6a56711dcc2e10490a82965850e4 | ||
- name: "Checkout" | ||
if: github.event.pull_request.head.repo.full_name == github.repository | ||
- | ||
uses: actions/checkout@v4 | ||
with: | ||
repository: ${{ github.event.pull_request.head.repo.full_name }} | ||
ref: ${{ github.event.pull_request.head.ref }} | ||
# Must be used to trigger workflow after push | ||
token: ${{ secrets.ACCESS_TOKEN }} | ||
|
||
# in forks, the token is not available - so we cannot use eit | ||
- name: "Checkout" | ||
if: github.event.pull_request.head.repo.full_name != github.repository | ||
uses: actions/checkout@v4 | ||
with: | ||
repository: ${{ github.event.pull_request.head.repo.full_name }} | ||
ref: ${{ github.event.pull_request.head.ref }} | ||
- run: echo "run on ${{ github.event.pull_request.head.repo.full_name }}" | ||
|
||
- name: "Install PHP" | ||
- | ||
uses: shivammathur/setup-php@v2 | ||
with: | ||
# PHP 7.4 is required, so Rector's code is PHP 8.2 compatible even after refactoring | ||
php-version: 7.4 | ||
coverage: none | ||
|
||
# see https://github.com/ramsey/composer-install | ||
- name: "Install Composer dependencies" | ||
uses: ramsey/composer-install@v2 | ||
- run: composer install --no-progress --ansi | ||
|
||
## First run Rector - here can't be --dry-run !!! it would stop the job with it and not commit anything in the future | ||
- name: "Run Rector" | ||
run: "composer fix:rector" | ||
|
||
- name: "Run Easy Coding Standard" | ||
run: "composer fix:style" | ||
- run: vendor/bin/rector process ${{ matrix.paths }} --ansi | ||
|
||
# see https://github.com/EndBug/add-and-commit | ||
- name: "Commit changes" | ||
- | ||
# commit only to core contributors who have repository access | ||
if: github.event.pull_request.head.repo.full_name == github.repository | ||
uses: EndBug/add-and-commit@v9.1.4 | ||
uses: stefanzweifel/git-auto-commit-action@v4 | ||
with: | ||
# The arguments for the `git add` command (see the paragraph below for more info) | ||
add: . | ||
message: "[CI] Rector Rectify" | ||
author_name: "GitHub Action" | ||
author_email: "action@github.com" | ||
env: | ||
# to get push access | ||
GITHUB_TOKEN: ${{ secrets.ACCESS_TOKEN }} | ||
commit_message: '[ci-review] Rector Rectify' | ||
commit_author: 'GitHub Action <actions@github.com>' | ||
commit_user_email: 'action@github.com' |