1
1
#! /usr/bin/env bash
2
2
# Usage: ./deploy-pr.sh --skip-build
3
- # deploys the current branch to a PR environment and posts login credentials to
3
+ # deploys the current branch to a PR environment and posts login credentials to
4
4
# [#pr-deployments](https://codercom.slack.com/archives/C05DNE982E8) Slack channel
5
5
# if --skip-build is passed, the build step will be skipped and the last build image will be used
6
6
@@ -9,24 +9,24 @@ set -euox pipefail
9
9
branchName=$( gh pr view --json headRefName | jq -r .headRefName)
10
10
11
11
if [[ " $branchName " == " main" ]]; then
12
- prNumber=$( git rev-parse --short HEAD)
12
+ prNumber=$( git rev-parse --short HEAD)
13
13
else
14
- prNumber=$( gh pr view --json number | jq -r .number)
14
+ prNumber=$( gh pr view --json number | jq -r .number)
15
15
fi
16
16
17
17
# if --skip-build is passed, the build job will be skipped and the last built image will be used
18
18
if [[ " $* " == * --skip-build* ]]; then
19
- skipBuild=true
20
- # check if the image exists
21
- foundTag=$( curl -fsSL https://github.com/coder/coder/pkgs/container/coder-preview | grep -o " $prNumber " | head -n 1)
22
- if [ -z " $foundTag " ]; then
23
- echo " Image not found"
24
- echo " " $prNumber " tag not found in ghcr.io/coder/coder-preview"
25
- echo " Please remove --skip-build and try again"
26
- exit 1
27
- fi
19
+ skipBuild=true
20
+ # check if the image exists
21
+ foundTag=$( curl -fsSL https://github.com/coder/coder/pkgs/container/coder-preview | grep -o " $prNumber " | head -n 1)
22
+ if [ -z " $foundTag " ]; then
23
+ echo " Image not found"
24
+ echo " " $prNumber " tag not found in ghcr.io/coder/coder-preview"
25
+ echo " Please remove --skip-build and try again"
26
+ exit 1
27
+ fi
28
28
else
29
- skipBuild=false
29
+ skipBuild=false
30
30
fi
31
31
32
32
gh workflow run pr-deploy.yaml --ref " $branchName " -f pr_number=" $imageTag " -f skip_build=" $skipBuild "
0 commit comments