@@ -25,32 +25,30 @@ jobs:
25
25
pr_commented :
26
26
if : (github.event_name == 'issue_comment' && contains(github.event.comment.body, '/deploy-pr') && (github.event.comment.author_association == 'MEMBER' || github.event.comment.author_association == 'COLLABORATOR' || github.event.comment.author_association == 'OWNER')) || github.event_name == 'workflow_dispatch'
27
27
outputs :
28
- PR_NUMBER : ${{ steps.pr_number .outputs.PR_NUMBER }}
29
- PR_TITLE : ${{ steps.pr_number .outputs.PR_TITLE }}
30
- PR_URL : ${{ steps.pr_number .outputs.PR_URL }}
31
- PR_BRANCH : ${{ steps.pr_number .outputs.PR_BRANCH }}
28
+ PR_NUMBER : ${{ steps.pr_info .outputs.PR_NUMBER }}
29
+ PR_TITLE : ${{ steps.pr_info .outputs.PR_TITLE }}
30
+ PR_URL : ${{ steps.pr_info .outputs.PR_URL }}
31
+ PR_BRANCH : ${{ steps.pr_info .outputs.PR_BRANCH }}
32
32
CODER_BASE_IMAGE_TAG : ${{ steps.set_tags.outputs.CODER_BASE_IMAGE_TAG }}
33
33
CODER_IMAGE_TAG : ${{ steps.set_tags.outputs.CODER_IMAGE_TAG }}
34
34
35
35
runs-on : " ubuntu-latest"
36
36
steps :
37
37
- name : Get PR number, title, and branch name
38
- id : pr_number
38
+ id : pr_info
39
39
run : |
40
- set -e pipefail
41
- if [[ ${{ github.event_name }} == ' workflow_dispatch' ]]; then
40
+ set -euxo pipefail
41
+ if [[ ${{ github.event_name }} == " workflow_dispatch" ]]; then
42
42
PR_NUMBER=${{ github.event.inputs.pr_number }}"
43
43
else
44
44
PR_NUMBER=${{ github.event.issue.number }}"
45
45
fi
46
- PR_TITLE=$(gh pr view $PR_NUMBER --json title | jq -r '.title')
47
- PR_BRANCH=$(gh pr view $PR_NUMBER --json headRefName | jq -r '.headRefName ')
46
+ PR_TITLE=$(curl -s -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" https://api.github.com/repos/coder/coder/pulls/$PR_NUMBER | jq -r '.title')
47
+ PR_BRANCH=$(curl -s -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" https://api.github.com/repos/coder/coder/pulls/$PR_NUMBER | jq -r '.head.ref ')
48
48
echo "PR_URL=https://github.com/coder/coder/pull/$PR_NUMBER" >> $GITHUB_OUTPUT
49
49
echo "PR_NUMBER=$PR_NUMBER" >> $GITHUB_OUTPUT
50
50
echo "PR_TITLE=$PR_TITLE" >> $GITHUB_OUTPUT
51
51
echo "PR_BRANCH=$PR_BRANCH" >> $GITHUB_OUTPUT
52
- env :
53
- GH_TOKEN : ${{ secrets.GITHUB_TOKEN }}
54
52
55
53
- name : Set required tags
56
54
id : set_tags
@@ -59,27 +57,27 @@ jobs:
59
57
echo "CODER_BASE_IMAGE_TAG=$CODER_BASE_IMAGE_TAG" >> $GITHUB_OUTPUT
60
58
echo "CODER_IMAGE_TAG=$CODER_IMAGE_TAG" >> $GITHUB_OUTPUT
61
59
env :
62
- CODER_BASE_IMAGE_TAG : ghcr.io/coder/coder-preview-base:pr${{ steps.pr_number .outputs.PR_NUMBER }}
63
- CODER_IMAGE_TAG : ghcr.io/coder/coder-preview:pr${{ steps.pr_number .outputs.PR_NUMBER }}
60
+ CODER_BASE_IMAGE_TAG : ghcr.io/coder/coder-preview-base:pr${{ steps.pr_info .outputs.PR_NUMBER }}
61
+ CODER_IMAGE_TAG : ghcr.io/coder/coder-preview:pr${{ steps.pr_info .outputs.PR_NUMBER }}
64
62
65
63
- name : Comment on PR
66
64
id : comment_id
67
65
uses : peter-evans/create-or-update-comment@v3
68
66
with :
69
- issue-number : ${{ steps.pr_number .outputs.PR_NUMBER }}
67
+ issue-number : ${{ steps.pr_info .outputs.PR_NUMBER }}
70
68
body : |
71
- :rocket: Deploying PR ${{ steps.pr_number .outputs.PR_NUMBER }} ...
69
+ :rocket: Deploying PR ${{ steps.pr_info .outputs.PR_NUMBER }} ...
72
70
:warning: This deployment will be deleted when the PR is closed.
73
- reactions : " - 1"
71
+ reactions : " + 1"
74
72
75
73
build :
76
74
needs : pr_commented
77
75
runs-on : ${{ github.repository_owner == 'coder' && 'buildjet-8vcpu-ubuntu-2204' || 'ubuntu-latest' }}
78
76
env :
79
77
DOCKER_CLI_EXPERIMENTAL : " enabled"
80
- CODER_IMAGE_TAG : ${{ needs.pr_commented.outputs.coder_image_tag }}
81
- PR_NUMBER : ${{ needs.pr_commented.outputs.pr_number }}
82
- PR_BRANCH : ${{ needs.pr_commented.outputs.pr_branch }}
78
+ CODER_IMAGE_TAG : ${{ needs.pr_commented.outputs.CODER_IMAGE_TAG }}
79
+ PR_NUMBER : ${{ needs.pr_commented.outputs.PR_NUMBER }}
80
+ PR_BRANCH : ${{ needs.pr_commented.outputs.PR_BRANCH }}
83
81
steps :
84
82
- name : Checkout
85
83
uses : actions/checkout@v3
@@ -239,10 +237,7 @@ jobs:
239
237
:heavy_check_mark: Deployed PR ${{ env.PR_NUMBER }} successfully.
240
238
:rocket: Access the deployment link [here](${{ env.PR_DEPLOYMENT_ACCESS_URL }}).
241
239
:warning: This deployment will be deleted when the PR is closed.
242
- reactions : |
243
- +1
244
- rocket
245
- reactions-edit-mode : replace
240
+ reactions : rocket
246
241
247
242
env :
248
243
PR_DEPLOYMENT_ACCESS_URL : " https://pr${{ env.PR_NUMBER }}.${{ secrets.PR_DEPLOYMENTS_DOMAIN }}"
0 commit comments