rector/.github/workflows/rector_ci.yaml

79 lines
3.0 KiB
YAML
Raw Normal View History

####
# 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 CI
on:
pull_request: null
push:
branches:
- master
jobs:
rector-ci:
runs-on: ubuntu-latest
if: github.event.pull_request.head.repo.full_name == github.repository
steps:
2020-03-11 22:31:16 +01:00
-
uses: actions/checkout@v2
with:
ref: ${{ github.event.pull_request.head.ref }} # Solves the not "You are not currently on a branch" problem, see https://github.com/actions/checkout/issues/124#issuecomment-586664611
token: ${{ secrets.ACCESS_TOKEN }} # Must be used to trigger workflow after push
2020-03-11 22:31:16 +01:00
-
uses: shivammathur/setup-php@v1
with:
php-version: 7.3
coverage: none
2020-03-11 22:31:16 +01:00
- run: composer install --no-progress
2020-03-19 11:35:49 +01:00
## First run Rector
- run: composer rector-ci-fix
2020-03-11 21:59:06 +01:00
-
2020-03-19 11:35:49 +01:00
name: Check for Rector modified files
2020-03-11 21:59:06 +01:00
id: git-check
2020-03-19 11:35:49 +01:00
run: echo ::set-output name=modified_rector::$(if git diff --exit-code --no-patch; then echo "false"; else echo "true"; fi)
2020-03-11 21:59:06 +01:00
2020-03-19 11:35:49 +01:00
- name: Git config
if: steps.git-check.outputs.modified_rector == 'true'
2020-03-11 21:59:06 +01:00
run: |
2020-03-12 21:11:38 +01:00
git config --global user.name 'rector-bot'
git config --global user.email 'tomas@getrector.org'
2020-03-19 11:35:49 +01:00
- name: Commit Rector changes
if: steps.git-check.outputs.modified_rector == 'true'
run: git commit -am "fixup! [Rector CI] Fixed Rector issues"
## Now, there might be coding standard issues after running Rector
-
if: steps.git-check.outputs.modified_rector == 'true'
run: composer fix-cs
-
name: Check for CS modified files
if: steps.git-check.outputs.modified_rector == 'true'
id: git-check
run: echo ::set-output name=modified_cs::$(if git diff --exit-code --no-patch; then echo "false"; else echo "true"; fi)
- name: Commit CS changes
if: steps.git-check.outputs.modified_cs == 'true'
run: git commit -am "fixup! [Rector CI] Fixed CS issues"
- name: Push changes
if: steps.git-check.outputs.modified_rector == 'true'
run: git push
# In case we want to fail this job when there are changed files, just add "exit 1"