2020-03-12 22:27:37 +01:00
|
|
|
####
|
|
|
|
# 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
|
|
|
|
####
|
2020-01-22 01:07:32 +01:00
|
|
|
name: Rector CI
|
|
|
|
|
|
|
|
on:
|
|
|
|
pull_request: null
|
|
|
|
|
|
|
|
jobs:
|
|
|
|
rector-ci:
|
2020-10-19 16:37:35 +02:00
|
|
|
strategy:
|
|
|
|
fail-fast: false
|
|
|
|
matrix:
|
|
|
|
directories:
|
|
|
|
- packages
|
|
|
|
- rules
|
|
|
|
- src
|
|
|
|
- tests
|
|
|
|
|
2020-01-22 01:07:32 +01:00
|
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
2020-10-28 21:47:23 +01:00
|
|
|
# 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
|
2020-10-27 16:51:44 +01:00
|
|
|
with:
|
|
|
|
# Must be used to trigger workflow after push
|
|
|
|
token: ${{ secrets.ACCESS_TOKEN }}
|
2020-03-11 22:31:16 +01:00
|
|
|
|
2020-10-28 21:47:23 +01:00
|
|
|
# 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
|
|
|
|
|
2020-01-22 01:07:32 +01:00
|
|
|
-
|
|
|
|
uses: shivammathur/setup-php@v1
|
|
|
|
with:
|
2020-09-01 19:56:30 +02:00
|
|
|
# PHP 7.2 is required, so Rector's code is PHP 7.2 compatible even after refactoring
|
|
|
|
php-version: 7.2
|
2020-01-22 01:07:32 +01:00
|
|
|
coverage: none
|
2020-10-30 14:50:38 +01:00
|
|
|
tools: composer:v2
|
2020-03-11 22:31:16 +01:00
|
|
|
|
2020-05-02 11:47:43 +02:00
|
|
|
- run: composer install --no-progress --ansi
|
2020-03-19 11:35:49 +01:00
|
|
|
|
2020-10-26 01:14:24 +01:00
|
|
|
## 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 rectify ${{ matrix.directories }} --config rector-ci.php --ansi --no-progress-bar
|
2020-10-26 12:28:32 +01:00
|
|
|
- run: vendor/bin/ecs check --match-git-diff --fix --ansi
|
2020-03-11 21:59:06 +01:00
|
|
|
|
|
|
|
-
|
2020-10-26 01:14:24 +01:00
|
|
|
uses: EndBug/add-and-commit@v5
|
|
|
|
with:
|
|
|
|
# The arguments for the `git add` command (see the paragraph below for more info)
|
|
|
|
add: .
|
|
|
|
message: "[ci-review] Rector Rectify"
|
|
|
|
author_name: rector-bot
|
|
|
|
author_email: tomas@getrector.org
|
|
|
|
env:
|
|
|
|
# to get push access
|
2020-10-27 15:00:39 +01:00
|
|
|
GITHUB_TOKEN: ${{ secrets.ACCESS_TOKEN }}
|