rector/.github/workflows/rector.yaml

80 lines
4.1 KiB
YAML

####
# 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
jobs:
rector:
strategy:
fail-fast: false
matrix:
directories:
#- rules
- rules/arguments rules/autodiscovery rules/cakephp rules/carbon rules/code-quality rules/code-quality-strict rules/coding-style rules/composer rules/dead-code rules/dead-doc-block rules/defluent rules/dependency-injection rules/doctrine rules/doctrine-code-quality rules/doctrine-gedmo-to-knplabs rules/downgrade-php70 rules/downgrade-php71 rules/downgrade-php72 rules/downgrade-php73 rules/naming rules/nette rules/nette-code-quality rules/nette-kdyby
- rules/downgrade-php74 rules/downgrade-php80 rules/early-return rules/generics rules/laravel rules/legacy rules/mockery-to-prophecy rules/mysql-to-mysqli rules/symfony3 rules/symfony4 rules/symfony5 rules/transform rules/type-declaration rules/visibility
- rules/nette-tester-to-phpunit rules/nette-to-symfony rules/nette-utils-code-quality rules/order rules/php-office rules/php-spec-to-phpunit rules/php52 rules/php53 rules/php54 rules/php55 rules/php56 rules/php70 rules/php71 rules/php72 rules/php73 rules/php74 rules/php80 rules/phpunit rules/phpunit-symfony rules/privatization rules/psr4 rules/removing rules/removing-static rules/renaming rules/restoration rules/sensio rules/symfony rules/symfony-code-quality rules/symfony-php-config rules/symfony2
- packages
- src
- tests
runs-on: ubuntu-latest
steps:
# workaround for missing secret in fork PRs - see https://github.com/actions/checkout/issues/298
# see https://github.com/rectorphp/rector/commit/d395e1c28b8e6a56711dcc2e10490a82965850e4
-
if: github.event.pull_request.head.repo.full_name == github.repository
uses: actions/checkout@v2
with:
# Must be used to trigger workflow after push
token: ${{ secrets.ACCESS_TOKEN }}
# in forks, the token is not available - so we cannot us eit
-
if: github.event.pull_request.head.repo.full_name != github.repository
uses: actions/checkout@v2
-
uses: shivammathur/setup-php@v2
with:
# PHP 7.3 is required, so Rector's code is PHP 7.3 compatible even after refactoring
php-version: 7.3
coverage: none
- 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
- run: bin/rector process ${{ matrix.directories }} --ansi --no-progress-bar
- run: vendor/bin/ecs check --match-git-diff --fix --ansi
# see https://github.com/EndBug/add-and-commit
-
# 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@v7.0.0
with:
# The arguments for the `git add` command (see the paragraph below for more info)
add: .
message: "[ci-review] Rector Rectify"
author_name: "kaizen-ci"
author_email: "info@kaizen-ci.org"
env:
# to get push access
GITHUB_TOKEN: ${{ secrets.ACCESS_TOKEN }}