Skip to content

ci: further improve pr deployments #8764

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 9 commits into from
Jul 27, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
add dry run flag
  • Loading branch information
matifali committed Jul 27, 2023
commit 24dc7c27ab3aea8d394c3688f76cb3f2e29e1700
18 changes: 15 additions & 3 deletions scripts/deploy-pr.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
# if --skip-build is passed, the build step will be skipped and the last build image will be used
# if --yes or -y is passed, the script will not ask for confirmation before deploying

set -euox pipefail
set -euo pipefail

# ask for user confirmation before deploying also skip confirmation if --yes or -y is passed
if [[ "$*" != *--yes* ]] && [[ "$*" != *-y* ]]; then
Expand All @@ -22,8 +22,9 @@ prNumber=$(gh pr view --json number | jq -r .number)
if [[ "$*" == *--skip-build* ]]; then
skipBuild=true
#check if the image exists
foundTag=$(curl -fsSL https://github.com/coder/coder/pkgs/container/coder-preview | grep -o "$prNumber" | head -n 1)
if [ -z "${foundTag}" ]; then
foundTag=$(curl -fsSL https://github.com/coder/coder/pkgs/container/coder-preview | grep -o "$prNumber" | head -n 1) || true
echo "foundTag is: '${foundTag}'"
if [[ -z "${foundTag}" ]]; then
echo "Image not found"
echo "${prNumber} tag not found in ghcr.io/coder/coder-preview"
echo "Please remove --skip-build and try again"
Expand All @@ -33,4 +34,15 @@ else
skipBuild=false
fi

## dry run with --dry-run or -n

if [[ "$*" == *--dry-run* ]] || [[ "$*" == *-n* ]]; then
echo "dry run"
echo "branchName: ${branchName}"
echo "prNumber: ${prNumber}"
echo "skipBuild: ${skipBuild}"
echo "gh workflow run pr-deploy.yaml --ref "${branchName}" -f pr_number="${prNumber}" -f skip_build="${skipBuild}""
exit 0
fi

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