Skip to content

Commit cc65580

Browse files
committed
remove --skip-build and add --force
1 parent 098e5e6 commit cc65580

File tree

3 files changed

+15
-30
lines changed

3 files changed

+15
-30
lines changed

.github/workflows/pr-deploy.yaml

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,16 @@ on:
1212
description: "PR number"
1313
type: number
1414
required: true
15-
skip_build:
16-
description: "Skip build job"
17-
required: false
18-
type: boolean
19-
default: false
2015
experiments:
2116
description: "Experiments to enable"
2217
required: false
2318
type: string
2419
default: "*"
20+
force:
21+
description: "Force new build and deploy"
22+
required: false
23+
type: boolean
24+
default: false
2525

2626
env:
2727
REPO: ghcr.io/coder/coder-preview
@@ -157,11 +157,8 @@ jobs:
157157
158158
build:
159159
needs: get_info
160-
# Skips the build job if the workflow was triggered by a workflow_dispatch event and the skip_build input is set to true
161-
# always run the build job if a pull_request event triggered the workflow
162-
if: |
163-
((github.event_name == 'workflow_dispatch' && github.event.inputs.skip_build == 'false') ||
164-
github.event_name == 'pull_request') && needs.get_info.outputs.BUILD == 'true'
160+
# Run build job only if there are changes in the files that we care about or if the workflow is manually triggered with --force
161+
if: needs.get_info.outputs.BUILD == 'true' || github.event.inputs.force == 'true'
165162
runs-on: ${{ github.repository_owner == 'coder' && 'buildjet-8vcpu-ubuntu-2204' || 'ubuntu-latest' }}
166163
env:
167164
DOCKER_CLI_EXPERIMENTAL: "enabled"

docs/CONTRIBUTING.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ You can test your changes by creating a PR deployment. There are two ways to do
8989

9090
#### Available options
9191

92-
- `-s` or `--skip-build`, force prevents the build of the Docker image.(generally not needed as we are intelligently checking if the image needs to be built)
92+
- `-f` or `--force`, force builds the Docker image. (generally not needed as we are intelligently checking if the image needs to be built)
9393
- `-e EXPERIMENT1,EXPERIMENT2` or `--experiments EXPERIMENT1,EXPERIMENT2`, will enable the specified experiments. (defaults to `*`)
9494
- `-n` or `--dry-run` will display the context without deployment. e.g., branch name and PR number, etc.
9595
- `-y` or `--yes`, will skip the CLI confirmation prompt.

scripts/deploy-pr.sh

Lines changed: 7 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
11
#!/usr/bin/env bash
2-
# Usage: ./deploy-pr.sh [--skip-build -s] [--dry-run -n] [--yes -y]
2+
# Usage: ./deploy-pr.sh [--dry-run -n] [--yes -y] [--experiments -e <experiments>] [--force -f]
33
# deploys the current branch to a PR environment and posts login credentials to
44
# [#pr-deployments](https://codercom.slack.com/archives/C05DNE982E8) Slack channel
55

66
set -euo pipefail
77

88
# default settings
9-
skipBuild=false
109
dryRun=false
1110
confirm=true
11+
force=false
1212
experiments=""
1313

1414
# parse arguments
1515
while (("$#")); do
1616
case "$1" in
17-
-s | --skip-build)
18-
skipBuild=true
17+
-f | --force)
18+
force=true
1919
shift
2020
;;
2121
-n | --dry-run)
@@ -63,30 +63,18 @@ fi
6363
branchName=$(gh pr view --json headRefName | jq -r .headRefName)
6464
prNumber=$(gh pr view --json number | jq -r .number)
6565

66-
if $skipBuild; then
67-
#check if the image exists
68-
foundTag=$(curl -fsSL https://github.com/coder/coder/pkgs/container/coder-preview | grep -o "$prNumber" | head -n 1) || true
69-
echo "foundTag is: '${foundTag}'"
70-
if [[ -z "${foundTag}" ]]; then
71-
echo "Image not found"
72-
echo "${prNumber} tag not found in ghcr.io/coder/coder-preview"
73-
echo "Please remove --skip-build and try again"
74-
exit 1
75-
fi
76-
fi
77-
7866
if $dryRun; then
7967
echo "dry run"
8068
echo "branchName: ${branchName}"
8169
echo "prNumber: ${prNumber}"
82-
echo "skipBuild: ${skipBuild}"
8370
echo "experiments: ${experiments}"
71+
echo "force: ${force}"
8472
exit 0
8573
fi
8674

8775
echo "branchName: ${branchName}"
8876
echo "prNumber: ${prNumber}"
89-
echo "skipBuild: ${skipBuild}"
9077
echo "experiments: ${experiments}"
78+
echo "force: ${force}"
9179

92-
gh workflow run pr-deploy.yaml --ref "${branchName}" -f "pr_number=${prNumber}" -f "skip_build=${skipBuild}" -f "experiments=${experiments}"
80+
gh workflow run pr-deploy.yaml --ref "${branchName}" -f "pr_number=${prNumber}" -f "experiments=${experiments}" -f "force=${force}"

0 commit comments

Comments
 (0)