File tree 2 files changed +21
-5
lines changed 2 files changed +21
-5
lines changed Original file line number Diff line number Diff line change 8
8
pr_number :
9
9
description : " PR number"
10
10
required : true
11
+ skip_build :
12
+ description : " Skip build job"
13
+ required : false
14
+ default : false
11
15
12
16
env :
13
17
REPO : ghcr.io/coder/coder-preview
73
77
74
78
build :
75
79
needs : pr_commented
80
+ # Skips the build job if the workflow was triggered by a workflow_dispatch event and the skip_build input is set to true
81
+ # or if the workflow was triggered by an issue_comment event and the comment body contains --skip-build
82
+ if : (github.event_name == 'workflow_dispatch' && github.event.inputs.skip_build == 'false') || (github.event_name == 'issue_comment' && contains(github.event.comment.body, '--skip-build') != true)
76
83
runs-on : ${{ github.repository_owner == 'coder' && 'buildjet-8vcpu-ubuntu-2204' || 'ubuntu-latest' }}
77
84
env :
78
85
DOCKER_CLI_EXPERIMENTAL : " enabled"
@@ -120,7 +127,8 @@ jobs:
120
127
121
128
deploy :
122
129
needs : [build, pr_commented]
123
- if : needs.build.result == 'success'
130
+ # Run deploy job only if build job was successful or skipped but not if it failed
131
+ if : needs.build.result != 'failure' && needs.build.result != 'cancelled'
124
132
runs-on : " ubuntu-latest"
125
133
env :
126
134
CODER_IMAGE_TAG : ${{ needs.pr_commented.outputs.CODER_IMAGE_TAG }}
Original file line number Diff line number Diff line change 1
1
#! /usr/bin/env bash
2
- # Usage: ./deploy-pr.sh
3
- # deploys the current branch to a PR environment and posts login credentials to [#pr-deployments](https://codercom.slack.com/archives/C05DNE982E8) Slack channel
2
+ # Usage: ./deploy-pr.sh --skip-build
3
+ # deploys the current branch to a PR environment and posts login credentials to
4
+ # [#pr-deployments](https://codercom.slack.com/archives/C05DNE982E8) Slack channel
5
+ # if --skip-build is passed, the build step will be skipped and the last build image will be used
6
+
4
7
set -euox pipefail
5
8
9
+ # if --skip-build is passed, the build step will be skipped and the last build image will be used
10
+ if [[ " $* " == * --skip-build* ]]; then
11
+ skipBuild=true
12
+ fi
13
+
6
14
branchName=$( gh pr view --json headRefName | jq -r .headRefName)
7
15
8
16
if [[ " $branchName " == " main" ]]; then
9
- gh workflow run pr-deploy.yaml --ref $branchName -f pr_number=$( git rev-parse --short HEAD)
17
+ gh workflow run pr-deploy.yaml --ref $branchName -f pr_number=$( git rev-parse --short HEAD) -f skip_build= $skipBuild
10
18
else
11
- gh workflow run pr-deploy.yaml --ref $branchName -f pr_number=$( gh pr view --json number | jq -r .number)
19
+ gh workflow run pr-deploy.yaml --ref $branchName -f pr_number=$( gh pr view --json number | jq -r .number) -f skip_build= $skipBuild
12
20
fi
You can’t perform that action at this time.
0 commit comments