From 0c4b437d981660ef3b57af8cbd3298688a3953c0 Mon Sep 17 00:00:00 2001 From: Arpit Mohan Date: Wed, 7 Oct 2020 06:37:49 +0530 Subject: [PATCH 1/2] Adding the condition to fix push vs pull_request_target commit checkouts --- .github/workflows/client.yml | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/.github/workflows/client.yml b/.github/workflows/client.yml index ad1929ec49..cf91382238 100644 --- a/.github/workflows/client.yml +++ b/.github/workflows/client.yml @@ -24,10 +24,16 @@ jobs: steps: # Checkout the code - - uses: actions/checkout@v2 + - name: Checkout the merged commit from PR and base branch + if: ${{ github.event_name == 'pull_request_target' }} + uses: actions/checkout@v2 with: ref: refs/pull/${{ github.event.pull_request.number }}/merge + - name: Checkout the head commit of the branch + if: ${{ github.event_name == 'push' }} + uses: actions/checkout@v2 + - name: Figure out the PR number run: echo ${{ github.event.pull_request.number }} @@ -103,10 +109,16 @@ jobs: steps: # Checkout the code - - uses: actions/checkout@v2 + - name: Checkout the merged commit from PR and base branch + if: ${{ github.event_name == 'pull_request_target' }} + uses: actions/checkout@v2 with: ref: refs/pull/${{ github.event.pull_request.number }}/merge + - name: Checkout the head commit of the branch + if: ${{ github.event_name == 'push' }} + uses: actions/checkout@v2 + - name: Use Node.js 10.16.3 uses: actions/setup-node@v1 with: @@ -208,9 +220,15 @@ jobs: steps: # Checkout the code - - uses: actions/checkout@v2 + - name: Checkout the merged commit from PR and base branch + if: ${{ github.event_name == 'pull_request_target' }} + uses: actions/checkout@v2 with: ref: refs/pull/${{ github.event.pull_request.number }}/merge + + - name: Checkout the head commit of the branch + if: ${{ github.event_name == 'push' }} + uses: actions/checkout@v2 - name: Download the react build artifact uses: actions/download-artifact@v2 From cb4221938b754bb2ec51f460f3cd0ee859f4be44 Mon Sep 17 00:00:00 2001 From: Arpit Mohan Date: Wed, 7 Oct 2020 06:45:17 +0530 Subject: [PATCH 2/2] Correcting the CI flow to include conditional steps for pull_request_target and push events This is because the pull_request_target runs on the base branch and NOT the merged commit. On the CI, this gives us incorrect results. --- .github/workflows/client.yml | 28 +++++++++++++++++++++++++--- 1 file changed, 25 insertions(+), 3 deletions(-) diff --git a/.github/workflows/client.yml b/.github/workflows/client.yml index aa320ac996..cf91382238 100644 --- a/.github/workflows/client.yml +++ b/.github/workflows/client.yml @@ -24,10 +24,16 @@ jobs: steps: # Checkout the code - - uses: actions/checkout@v2 + - name: Checkout the merged commit from PR and base branch + if: ${{ github.event_name == 'pull_request_target' }} + uses: actions/checkout@v2 with: ref: refs/pull/${{ github.event.pull_request.number }}/merge + - name: Checkout the head commit of the branch + if: ${{ github.event_name == 'push' }} + uses: actions/checkout@v2 + - name: Figure out the PR number run: echo ${{ github.event.pull_request.number }} @@ -103,7 +109,15 @@ jobs: steps: # Checkout the code - - uses: actions/checkout@v2 + - name: Checkout the merged commit from PR and base branch + if: ${{ github.event_name == 'pull_request_target' }} + uses: actions/checkout@v2 + with: + ref: refs/pull/${{ github.event.pull_request.number }}/merge + + - name: Checkout the head commit of the branch + if: ${{ github.event_name == 'push' }} + uses: actions/checkout@v2 - name: Use Node.js 10.16.3 uses: actions/setup-node@v1 @@ -206,7 +220,15 @@ jobs: steps: # Checkout the code - - uses: actions/checkout@v2 + - name: Checkout the merged commit from PR and base branch + if: ${{ github.event_name == 'pull_request_target' }} + uses: actions/checkout@v2 + with: + ref: refs/pull/${{ github.event.pull_request.number }}/merge + + - name: Checkout the head commit of the branch + if: ${{ github.event_name == 'push' }} + uses: actions/checkout@v2 - name: Download the react build artifact uses: actions/download-artifact@v2