Skip to content

Commit 664248b

Browse files
committed
feat: get correct checkout ref in issue_comment event
1 parent 28b1eb5 commit 664248b

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

.github/workflows/deploy-to-control-plane-review.yml

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,18 @@ jobs:
3232
runs-on: ubuntu-latest
3333

3434
steps:
35-
- name: Check out the repo
36-
uses: actions/checkout@v2
35+
- name: Get PR HEAD Ref
36+
if: ${{ github.event_name == 'issue_comment' }}
37+
id: getRef
38+
run: echo "PR_REF=$(gh pr view $PR_NUMBER --repo ${{ github.repository }} --json headRefName | jq -r '.headRefName')" >> $GITHUB_OUTPUT
39+
env:
40+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
41+
42+
- name: Checkout source code from Github
43+
uses: actions/checkout@v4
44+
with:
45+
fetch-depth: 0
46+
ref: ${{ steps.getRef.outputs.PR_REF || github.ref }}
3747

3848
- name: Add GitHub Comment
3949
if: ${{ github.event_name == 'issue_comment' }}
@@ -48,6 +58,7 @@ jobs:
4858
})
4959
5060
- name: Get PR number
61+
if: ${{ github.event_name != 'issue_comment' }}
5162
run: |
5263
echo "GITHUB_REPOSITORY: \"$GITHUB_REPOSITORY\""
5364
if [ -z "$PR_NUMBER" ]; then

0 commit comments

Comments
 (0)