Skip to content

Commit 7447bfa

Browse files
authored
fix: checkout correct branch for PR deployment (#8721)
1 parent dfb1a1d commit 7447bfa

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

.github/workflows/pr-deploy.yaml

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,26 +28,29 @@ jobs:
2828
PR_NUMBER: ${{ steps.pr_number.outputs.PR_NUMBER }}
2929
PR_TITLE: ${{ steps.pr_number.outputs.PR_TITLE }}
3030
PR_URL: ${{ steps.pr_number.outputs.PR_URL }}
31+
PR_BRANCH: ${{ steps.pr_number.outputs.PR_BRANCH }}
3132
COMMENT_ID: ${{ steps.comment_id.outputs.comment-id }}
3233
CODER_BASE_IMAGE_TAG: ${{ steps.set_tags.outputs.CODER_BASE_IMAGE_TAG }}
3334
CODER_IMAGE_TAG: ${{ steps.set_tags.outputs.CODER_IMAGE_TAG }}
3435

3536
runs-on: "ubuntu-latest"
3637
steps:
37-
- name: Get PR number and title
38+
- name: Get PR number, title, and branch name
3839
id: pr_number
3940
run: |
4041
set -euxo pipefail
4142
if [[ ${{ github.event_name }} == "workflow_dispatch" ]]; then
4243
PR_NUMBER=${{ github.event.inputs.pr_number }}
43-
PR_TITLE=$(curl -sSL -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" "https://api.github.com/repos/coder/coder/pulls/$PR_NUMBER" | jq -r '.title')
44+
PR_TITLE=$(gh pr view $PR_NUMBER --json title | jq -r '.title')
4445
else
4546
PR_NUMBER=${{ github.event.issue.number }}
4647
PR_TITLE='${{ github.event.issue.title }}'
4748
fi
49+
PR_BRANCH=$(gh pr view $PR_NUMBER --json headRefName | jq -r '.headRefName')
4850
echo "PR_URL=https://github.com/coder/coder/pull/$PR_NUMBER" >> $GITHUB_OUTPUT
4951
echo "PR_NUMBER=$PR_NUMBER" >> $GITHUB_OUTPUT
5052
echo "PR_TITLE=$PR_TITLE" >> $GITHUB_OUTPUT
53+
echo "PR_BRANCH=$PR_BRANCH" >> $GITHUB_OUTPUT
5154
5255
- name: Set required tags
5356
id: set_tags
@@ -85,10 +88,12 @@ jobs:
8588
DOCKER_CLI_EXPERIMENTAL: "enabled"
8689
CODER_IMAGE_TAG: ${{ needs.pr_commented.outputs.coder_image_tag }}
8790
PR_NUMBER: ${{ needs.pr_commented.outputs.pr_number }}
91+
PR_BRANCH: ${{ needs.pr_commented.outputs.pr_branch }}
8892
steps:
8993
- name: Checkout
9094
uses: actions/checkout@v3
9195
with:
96+
ref: ${{ env.PR_BRANCH }}
9297
fetch-depth: 0
9398

9499
- name: Setup Node

0 commit comments

Comments
 (0)