From 8c7a4fd121dd8a8f6a7716f61498c59f267621b6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fabiano=20Fid=C3=AAncio?= Date: Fri, 1 Sep 2023 11:23:31 +0200 Subject: [PATCH] gha: Rebase atop of the target branch MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit We have two scenarios we care about this, `pull_request` and `pull_request_target` events triggered a job. `pull_request` event: When using the checkout action, it'll already provide a "rebased atop of main" repo for us, nothing else is needed, and that's basically what we already have as part of the jobs in our CI. `pull_request_target` event: This one is a little bit tricky, as the checkout action, unless passing a spsecific repo, give us the PR checked out rebased atop of the HEAD of the PR branch. Jeremi Piotrowski nicely pointed out that we could use github.event.pull_request.merge_commit_sha instead, which is the result of the PR's branch with the official repo target branch. Now, the only cases where the contributor's rebase would still be needed is when the action itself has been changed. Fixes: #7414 Signed-off-by: Fabiano FidĂȘncio (cherry picked from commit ac939c458cde2286f15b0fa3bbf43a3aae7778d6) --- .github/workflows/add-pr-sizing-label.yaml | 2 ++ .github/workflows/ci-on-push.yaml | 2 +- .github/workflows/move-issues-to-in-progress.yaml | 2 ++ .github/workflows/require-pr-porting-labels.yaml | 2 ++ 4 files changed, 7 insertions(+), 1 deletion(-) diff --git a/.github/workflows/add-pr-sizing-label.yaml b/.github/workflows/add-pr-sizing-label.yaml index b8d498363..b972616fa 100644 --- a/.github/workflows/add-pr-sizing-label.yaml +++ b/.github/workflows/add-pr-sizing-label.yaml @@ -22,6 +22,8 @@ jobs: steps: - name: Checkout code uses: actions/checkout@v3 + with: + ref: ${{ github.event.pull_request.merge_commit_sha }} - name: Install PR sizing label script run: | diff --git a/.github/workflows/ci-on-push.yaml b/.github/workflows/ci-on-push.yaml index e1f3eaf96..f37f1b91c 100644 --- a/.github/workflows/ci-on-push.yaml +++ b/.github/workflows/ci-on-push.yaml @@ -25,7 +25,7 @@ jobs: if: ${{ contains(github.event.pull_request.labels.*.name, 'ok-to-test') }} uses: ./.github/workflows/ci.yaml with: - commit-hash: ${{ github.event.pull_request.head.sha }} + commit-hash: ${{ github.event.pull_request.merge_commit_sha }} pr-number: ${{ github.event.pull_request.number }} tag: ${{ github.event.pull_request.number }}-${{ github.event.pull_request.head.sha }} secrets: inherit diff --git a/.github/workflows/move-issues-to-in-progress.yaml b/.github/workflows/move-issues-to-in-progress.yaml index 64a453d64..2c4c3d2c8 100644 --- a/.github/workflows/move-issues-to-in-progress.yaml +++ b/.github/workflows/move-issues-to-in-progress.yaml @@ -39,6 +39,8 @@ jobs: - name: Checkout code to allow hub to communicate with the project if: ${{ !contains(github.event.pull_request.labels.*.name, 'force-skip-ci') }} uses: actions/checkout@v3 + with: + ref: ${{ github.event.pull_request.merge_commit_sha }} - name: Move issue to "In progress" if: ${{ !contains(github.event.pull_request.labels.*.name, 'force-skip-ci') }} diff --git a/.github/workflows/require-pr-porting-labels.yaml b/.github/workflows/require-pr-porting-labels.yaml index ea3016b5a..a06bbbf96 100644 --- a/.github/workflows/require-pr-porting-labels.yaml +++ b/.github/workflows/require-pr-porting-labels.yaml @@ -37,6 +37,8 @@ jobs: - name: Checkout code to allow hub to communicate with the project if: ${{ !contains(github.event.pull_request.labels.*.name, 'force-skip-ci') }} uses: actions/checkout@v3 + with: + ref: ${{ github.event.pull_request.merge_commit_sha }} - name: Install porting checker script run: |