From 4a78c36f43f87265ec975225e397d2a02b2cdbf3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20M=C3=BCnch?= Date: Thu, 30 Dec 2021 18:28:13 +0100 Subject: [PATCH] Backport checkout logic for PRs from Magerun 2 project --- .github/workflows/ci.yml | 49 ++++++++++++++++++++++++++++++++++++---- 1 file changed, 44 insertions(+), 5 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e8de2ba42..e21c2da09 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -8,7 +8,7 @@ on: - 'bugfix/*' - 'feature/*' - 'release/*' - pull_request: + pull_request_target: branches: - 'master' - 'develop' @@ -18,7 +18,16 @@ jobs: name: PHP Composer runs-on: 'ubuntu-18.04' steps: - - uses: actions/checkout@v2 + - name: Checkout PR + uses: actions/checkout@v2 + if: github.event_name == 'pull_request_target' + with: + ref: ${{ github.event.pull_request.head.sha }} + + - name: Checkout HEAD + uses: actions/checkout@v2 + if: github.event_name == 'push' + - uses: symfonycorp/security-checker-action@v2 - uses: shivammathur/setup-php@v2 @@ -65,7 +74,16 @@ jobs: SETUP_DB_PASS: root steps: - - uses: actions/checkout@v2 + - name: Checkout PR + uses: actions/checkout@v2 + if: github.event_name == 'pull_request_target' + with: + ref: ${{ github.event.pull_request.head.sha }} + + - name: Checkout HEAD + uses: actions/checkout@v2 + if: github.event_name == 'push' + - uses: shivammathur/setup-php@v2 with: php-version: ${{ matrix.php-version }} @@ -83,7 +101,17 @@ jobs: runs-on: ubuntu-18.04 steps: - {name: mysqld,shell: bash,run: 'sudo systemctl start mysql.service'} - - uses: actions/checkout@v2 + + - name: Checkout PR + uses: actions/checkout@v2 + if: github.event_name == 'pull_request_target' + with: + ref: ${{ github.event.pull_request.head.sha }} + + - name: Checkout HEAD + uses: actions/checkout@v2 + if: github.event_name == 'push' + - uses: actions/cache@v2 with: path: | @@ -110,9 +138,20 @@ jobs: runs-on: ubuntu-18.04 steps: - {name: mysqld,shell: bash,run: 'sudo systemctl start mysql.service'} - - uses: actions/checkout@v2 + + - name: Checkout PR + uses: actions/checkout@v2 + if: github.event_name == 'pull_request_target' with: fetch-depth: 0 + ref: ${{ github.event.pull_request.head.sha }} + + - name: Checkout HEAD + uses: actions/checkout@v2 + with: + fetch-depth: 0 + if: github.event_name == 'push' + - uses: shivammathur/setup-php@v2 with: