1
1
# This action will trigger when
2
- # 1. A PR is commented on with `/deploy-pr`
3
- # 2. when the workflow is manually triggered
4
- # 3. ./scripts/deploy_pr.sh is run locally
5
- # 4. when a PR is updated
2
+ # 1. when the workflow is manually triggered
3
+ # 2. ./scripts/deploy_pr.sh is run locally
4
+ # 3. when a PR is updated
6
5
name : Deploy PR
7
6
on :
8
- issue_comment :
9
- types : created
10
7
pull_request :
11
8
types : synchronize
12
9
workflow_dispatch :
@@ -35,12 +32,12 @@ permissions:
35
32
pull-requests : write
36
33
37
34
concurrency :
38
- group : ${{ github.workflow }}-PR-${{ github.event.pull_request.number || github.event.issue.number || github.event. inputs.pr_number }}
35
+ group : ${{ github.workflow }}-PR-${{ github.event.pull_request.number || github.event.inputs.pr_number }}
39
36
cancel-in-progress : true
40
37
41
38
jobs :
42
39
get_info :
43
- 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' || github.event_name == 'pull_request'
40
+ if : github.event_name == 'workflow_dispatch' || github.event_name == 'pull_request'
44
41
outputs :
45
42
PR_NUMBER : ${{ steps.pr_info.outputs.PR_NUMBER }}
46
43
PR_TITLE : ${{ steps.pr_info.outputs.PR_TITLE }}
57
54
id : pr_info
58
55
run : |
59
56
set -euxo pipefail
60
- PR_NUMBER=${{ github.event.inputs.pr_number || github.event.pull_request.number || github.event.issue.number }}
57
+ PR_NUMBER=${{ github.event.inputs.pr_number || github.event.pull_request.number }}
61
58
PR_TITLE=$(curl -s -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" https://api.github.com/repos/coder/coder/pulls/$PR_NUMBER | jq -r '.title')
62
59
PR_BRANCH=$(curl -s -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" https://api.github.com/repos/coder/coder/pulls/$PR_NUMBER | jq -r '.head.ref')
63
60
echo "PR_URL=https://github.com/coder/coder/pull/$PR_NUMBER" >> $GITHUB_OUTPUT
97
94
98
95
- name : Comment on PR
99
96
id : comment_id
100
- if : github.event_name == 'issue_comment'
101
97
uses : peter-evans/create-or-update-comment@v3
102
98
with :
103
99
issue-number : ${{ steps.pr_info.outputs.PR_NUMBER }}
@@ -148,7 +144,6 @@ jobs:
148
144
# alwyas run the build job if the workflow was triggered by a pull_request event
149
145
if : |
150
146
(github.event_name == 'workflow_dispatch' && github.event.inputs.skip_build == 'false') ||
151
- (github.event_name == 'issue_comment' && contains(github.event.comment.body, '--skip-build') == false) ||
152
147
(github.event_name == 'pull_request' && needs.get_info.outputs.NEW == 'false')
153
148
runs-on : ${{ github.repository_owner == 'coder' && 'buildjet-8vcpu-ubuntu-2204' || 'ubuntu-latest' }}
154
149
env :
@@ -299,29 +294,17 @@ jobs:
299
294
--from-literal=url="postgres://coder:coder@coder-db-postgresql.pr${{ env.PR_NUMBER }}.svc.cluster.local:5432/coder?sslmode=disable"
300
295
301
296
- name : Get experiments
302
- if : needs.get_info.outputs.NEW == 'true'
303
297
id : get_experiments
304
298
run : |
305
299
set -euxo pipefail
306
300
if [[ ${{ github.event_name }} == "workflow_dispatch" ]]; then
307
301
experiments=${{ github.event.inputs.experiments }}
308
302
else
309
- # extract experiments part
310
- extracted_experiments=$(echo "$COMMENT_BODY" | grep -oP '(?<=--experiments )[^ ]+')
311
- # Validate that the experiments is a comma-separated list of alphanumeric strings, "*", or "-"
312
- if [[ $extracted_experiments =~ ^[a-zA-Z0-9_*,\"-]+$ ]]; then
313
- experiments=$extracted_experiments
314
- else
315
- echo "Invalid input: $extracted_experiments"
316
- exit 1
317
- fi
303
+ experiments='*' # enable all experiments by default
318
304
fi
319
305
echo "experiments=$experiments" >> $GITHUB_OUTPUT
320
- env :
321
- COMMENT_BODY : ${{ github.event.comment.body || '' }}
322
306
323
307
- name : Create values.yaml
324
- if : needs.get_info.outputs.NEW == 'true'
325
308
run : |
326
309
cat <<EOF > pr-deploy-values.yaml
327
310
coder:
@@ -346,7 +329,7 @@ jobs:
346
329
- name: "CODER_WILDCARD_ACCESS_URL"
347
330
value: "*.${{ env.PR_DEPLOYMENT_ACCESS_URL }}"
348
331
- name: "CODER_EXPERIMENTS"
349
- value: "*, ${{ steps.get_experiments.outputs.experiments }}"
332
+ value: "${{ steps.get_experiments.outputs.experiments }}"
350
333
- name: CODER_PG_CONNECTION_URL
351
334
valueFrom:
352
335
secretKeyRef:
@@ -365,18 +348,10 @@ jobs:
365
348
- name : Install Helm chart
366
349
run : |
367
350
set -euxo pipefail
368
- # if the deployment already exists, we need to upgrade it by resuing the existing values
369
- if [[ ${{ needs.get_info.outputs.NEW }} == "false" ]]; then
370
- helm upgrade --install "pr${{ env.PR_NUMBER }}" ./helm \
371
- --namespace "pr${{ env.PR_NUMBER }}" \
372
- --reuse-values \
373
- --force
374
- else
375
- helm upgrade --install "pr${{ env.PR_NUMBER }}" ./helm \
376
- --namespace "pr${{ env.PR_NUMBER }}" \
377
- --values ./pr-deploy-values.yaml \
378
- --force
379
- fi
351
+ helm upgrade --install "pr${{ env.PR_NUMBER }}" ./helm \
352
+ --namespace "pr${{ env.PR_NUMBER }}" \
353
+ --values ./pr-deploy-values.yaml \
354
+ --force
380
355
381
356
- name : Install coder-logstream-kube
382
357
if : needs.get_info.outputs.NEW == 'true'
0 commit comments