Skip to content

Commit

Permalink
Alternative Rector workflow on check repo before steps run (#3440)
Browse files Browse the repository at this point in the history
* Alternative Rector workflow on check repo before steps run

* show display repo name to check

* check full name

* try add unused property

* [ci-review] Rector Rectify

* update templaet

---------

Co-authored-by: GitHub Action <actions@github.com>
  • Loading branch information
samsonasik and actions-user committed Mar 2, 2023
1 parent efc969e commit f56a053
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 24 deletions.
16 changes: 2 additions & 14 deletions .github/workflows/rector.yaml
Expand Up @@ -5,9 +5,6 @@ on:

jobs:
rector:
# Don't run on forks.
if: github.repository == 'rectorphp/rector-src'

strategy:
fail-fast: false
matrix:
Expand All @@ -19,20 +16,15 @@ jobs:
runs-on: ubuntu-latest
timeout-minutes: 8

if: github.event.pull_request.head.repo.full_name == 'rectorphp/rector-src'
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@v3
with:
# Must be used to trigger workflow after push
token: ${{ secrets.ACCESS_TOKEN }}

# in forks, the token is not available - so we cannot use it
-
if: github.event.pull_request.head.repo.full_name != github.repository
uses: actions/checkout@v3
- run: echo "run on ${{ github.event.pull_request.head.repo.full_name }}"

-
uses: shivammathur/setup-php@v2
Expand All @@ -46,12 +38,8 @@ jobs:
## 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.paths }} --ansi

- run: vendor/bin/ecs check --fix --ansi

# see https://github.com/rectorphp/rector/issues/7579
-
# commit only to core contributors who have repository access
if: github.event.pull_request.head.repo.full_name == github.repository
uses: stefanzweifel/git-auto-commit-action@v4
with:
commit_message: '[ci-review] Rector Rectify'
Expand Down
11 changes: 1 addition & 10 deletions templates/rector-github-action-check.yaml
Expand Up @@ -6,24 +6,16 @@ on:

jobs:
rector:
# Don't run on forks.
if: github.repository == '__CURRENT_REPOSITORY__'
runs-on: ubuntu-latest
if: github.event.pull_request.head.repo.full_name == '__CURRENT_REPOSITORY__'
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@v3
with:
# Must be used to trigger workflow after push
token: ${{ secrets.ACCESS_TOKEN }}

# in forks, the token is not available - so we cannot use it
-
if: github.event.pull_request.head.repo.full_name != github.repository
uses: actions/checkout@v3

-
uses: shivammathur/setup-php@v2
with:
Expand All @@ -36,7 +28,6 @@ jobs:

-
# commit only to core contributors who have repository access
if: github.event.pull_request.head.repo.full_name == github.repository
uses: stefanzweifel/git-auto-commit-action@v4
with:
commit_message: '[rector] Rector fixes'
Expand Down

0 comments on commit f56a053

Please sign in to comment.