-
Notifications
You must be signed in to change notification settings - Fork 170
chore: Support --end <front|back> in PR-to-staging deployment script
#3650
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -1,25 +1,31 @@ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| #!/usr/bin/env bash | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| set -euo pipefail | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # Usage: ./deploy-pr-to-beta [--staging-a|-sa | --staging-b|-sb | --staging-c|-sc | --staging <CANISTER_ID>] <PR_NUMBER> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # Usage: ./deploy-pr-to-beta [--staging-a|-sa | --staging-b|-sb | --staging-c|-sc | --staging <CANISTER_ID>] --end <front|back> <PR_NUMBER> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| print_usage() { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| cat <<EOF | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Usage: $0 [--staging-a|-sa | --staging-b|-sb | --staging-c|-sc | --staging <CANISTER_ID>] <PR_NUMBER> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Usage: $0 [--staging-a|-sa | --staging-b|-sb | --staging-c|-sc | --staging <CANISTER_ID>] --end <front|back> <PR_NUMBER> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Select which staging canister to upgrade. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Select which staging canister to upgrade and which end(s) to deploy. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Options: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| --staging-a, -sa Use Staging A (fgte5-ciaaa-aaaad-aaatq-cai) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| --staging-b, -sb Use Staging B (jqajs-xiaaa-aaaad-aab5q-cai) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| --staging-c, -sc Use Staging C (y2aaj-miaaa-aaaad-aacxq-cai) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| --staging <CANISTER_ID> Use the provided canister id | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| --end <front|back> Which end(s) to deploy (can be specified multiple times) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| -fe Shortcut for --end front | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| -be Shortcut for --end back | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| -h, --help Show this help | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| EOF | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| PR_NUMBER="" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| STAGING_CANISTER_ID="" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| STAGING_NAME="" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| DEPLOY_FRONT=false | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| DEPLOY_BACK=false | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| while [[ $# -gt 0 ]]; do | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| case "$1" in | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -29,14 +35,17 @@ while [[ $# -gt 0 ]]; do | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| ;; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| -sa|--staging-a) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| STAGING_CANISTER_ID="fgte5-ciaaa-aaaad-aaatq-cai" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| STAGING_NAME="a" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| shift | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ;; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| -sb|--staging-b) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| STAGING_CANISTER_ID="jqajs-xiaaa-aaaad-aab5q-cai" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| STAGING_NAME="b" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| shift | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ;; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| -sc|--staging-c) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| STAGING_CANISTER_ID="y2aaj-miaaa-aaaad-aacxq-cai" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| STAGING_NAME="c" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| shift | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ;; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| --staging) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -47,6 +56,33 @@ while [[ $# -gt 0 ]]; do | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| exit 1 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| fi | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| STAGING_CANISTER_ID="$1" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| STAGING_NAME="custom" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| shift | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ;; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| --end) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| shift | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if [ $# -eq 0 ]; then | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| echo "Error: --end requires an argument (front or back)" >&2 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| print_usage | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| exit 1 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| fi | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| case "$1" in | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| front) DEPLOY_FRONT=true ;; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| back) DEPLOY_BACK=true ;; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| *) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| echo "Error: --end value must be 'front' or 'back', got '$1'" >&2 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| print_usage | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| exit 1 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ;; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| esac | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| shift | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ;; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| -fe) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| DEPLOY_FRONT=true | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| shift | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ;; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| -be) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| DEPLOY_BACK=true | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| shift | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ;; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| --) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -83,25 +119,153 @@ if [ -z "$STAGING_CANISTER_ID" ]; then | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| exit 1 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| fi | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if [ "$DEPLOY_FRONT" = false ] && [ "$DEPLOY_BACK" = false ]; then | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| echo "Error: --end must be specified (use --end front, --end back, -fe, or -be)" >&2 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| print_usage | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| exit 1 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| fi | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if [ "$DEPLOY_FRONT" = true ] && [ "$STAGING_NAME" != "a" ]; then | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| echo "Error: Frontend deployment is not yet supported for Staging B, C, or custom canister IDs. Use --staging-a/-sa for frontend deployment." >&2 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| exit 1 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| fi | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| SCRIPTS_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ROOT_DIR="$SCRIPTS_DIR/.." | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| cd "$ROOT_DIR" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| REPO="dfinity/internet-identity" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| WORKFLOW_FILE="canister-tests.yml" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ARTIFACT_NAME="internet_identity_production.wasm.gz" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ZIP_FILE="$ARTIFACT_NAME.zip" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| EXTRACTED_FILE="$ARTIFACT_NAME" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| WALLET_CANISTER_ID="cvthj-wyaaa-aaaad-aaaaq-cai" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| BETA_CANISTER_ID="$STAGING_CANISTER_ID" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| FRONTEND_CANISTER_ID="gjxif-ryaaa-aaaad-ae4ka-cai" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # ------------------------- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # Prompt for a single Candid field value. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # Usage: prompt_field <field_label> <current_value> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # Prints the (possibly updated) value to stdout. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # ------------------------- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| prompt_field() { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| local label="$1" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| local current="$2" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| echo "" >&2 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| echo " $label = $current" >&2 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| read -r -p " Keep current value? [Y/n]: " answer </dev/tty >&2 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if [[ "$answer" =~ ^[Nn] ]]; then | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| read -r -p " Enter new value for $label: " new_value </dev/tty >&2 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| echo "$new_value" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| else | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| echo "$current" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| fi | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # ------------------------- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # Build InternetIdentityFrontendInit Candid argument interactively. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # Fetches current config from the canister, then prompts field-by-field. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # Sets FRONTEND_INSTALL_ARG with the resulting Candid record. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # ------------------------- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| build_frontend_install_arg() { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| local canister_id="$1" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| local config_url="https://${canister_id}.icp0.io/.config" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| echo "" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| echo "Fetching current frontend config from $config_url ..." | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| local raw_config | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| raw_config=$(curl -sfL "$config_url") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if [ -z "$raw_config" ]; then | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| echo "Error: Could not fetch current config from $config_url" >&2 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| exit 1 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| fi | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| echo "" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| echo "Current frontend config:" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| echo "$raw_config" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| echo "" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| echo "Configure install arguments (press Enter to keep each current value):" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # Parse individual fields from the Candid text output. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # We use grep + sed to extract the value portion after "field_name = ". | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| local current_backend_canister_id | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| current_backend_canister_id=$(echo "$raw_config" | grep 'backend_canister_id' | sed 's/.*= *//;s/ *;$//') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| local current_backend_origin | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| current_backend_origin=$(echo "$raw_config" | grep 'backend_origin' | sed 's/.*= *//;s/ *;$//') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| local current_related_origins | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| current_related_origins=$(echo "$raw_config" | sed -n '/related_origins/,/}/p' | tr '\n' ' ' | sed 's/.*= *//;s/ *;[[:space:]]*$//') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| local current_fetch_root_key | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| current_fetch_root_key=$(echo "$raw_config" | grep 'fetch_root_key' | sed 's/.*= *//;s/ *;$//') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| local current_analytics_config | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| current_analytics_config=$(echo "$raw_config" | grep 'analytics_config' | sed 's/.*= *//;s/ *;$//') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| local current_dummy_auth | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| current_dummy_auth=$(echo "$raw_config" | grep 'dummy_auth' | sed 's/.*= *//;s/ *;$//') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+186
to
+198
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # We use grep + sed to extract the value portion after "field_name = ". | |
| local current_backend_canister_id | |
| current_backend_canister_id=$(echo "$raw_config" | grep 'backend_canister_id' | sed 's/.*= *//;s/ *;$//') | |
| local current_backend_origin | |
| current_backend_origin=$(echo "$raw_config" | grep 'backend_origin' | sed 's/.*= *//;s/ *;$//') | |
| local current_related_origins | |
| current_related_origins=$(echo "$raw_config" | sed -n '/related_origins/,/}/p' | tr '\n' ' ' | sed 's/.*= *//;s/ *;[[:space:]]*$//') | |
| local current_fetch_root_key | |
| current_fetch_root_key=$(echo "$raw_config" | grep 'fetch_root_key' | sed 's/.*= *//;s/ *;$//') | |
| local current_analytics_config | |
| current_analytics_config=$(echo "$raw_config" | grep 'analytics_config' | sed 's/.*= *//;s/ *;$//') | |
| local current_dummy_auth | |
| current_dummy_auth=$(echo "$raw_config" | grep 'dummy_auth' | sed 's/.*= *//;s/ *;$//') | |
| # Extract the value portion after "field_name =" up to the terminating ";". | |
| local current_backend_canister_id | |
| current_backend_canister_id=$(echo "$raw_config" | grep 'backend_canister_id' | sed -n 's/.*backend_canister_id *= *\([^;]*\);.*/\1/p') | |
| local current_backend_origin | |
| current_backend_origin=$(echo "$raw_config" | grep 'backend_origin' | sed -n 's/.*backend_origin *= *\([^;]*\);.*/\1/p') | |
| local current_related_origins | |
| current_related_origins=$(echo "$raw_config" | tr '\n' ' ' | sed -n 's/.*related_origins *= *\([^;]*\);.*/\1/p') | |
| local current_fetch_root_key | |
| current_fetch_root_key=$(echo "$raw_config" | grep 'fetch_root_key' | sed -n 's/.*fetch_root_key *= *\([^;]*\);.*/\1/p') | |
| local current_analytics_config | |
| current_analytics_config=$(echo "$raw_config" | grep 'analytics_config' | sed -n 's/.*analytics_config *= *\([^;]*\);.*/\1/p') | |
| local current_dummy_auth | |
| current_dummy_auth=$(echo "$raw_config" | grep 'dummy_auth' | sed -n 's/.*dummy_auth *= *\([^;]*\);.*/\1/p') |
Copilot
AI
Mar 6, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This script now relies on didc for frontend deployment, but there’s no preflight check. If didc isn’t installed, the script will fail with a generic "command not found" due to set -e. Add an explicit command -v didc check when --end front is requested and emit a clear actionable error message (and possibly a hint on how to install it).
Copilot
AI
Mar 6, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
By filtering to only successful completed runs (select(.status == "completed" and .conclusion == "success")), the later failure case now means “no successful run found” rather than “no run found”. Consider updating the associated error message accordingly so users aren’t misled when runs exist but haven’t succeeded yet.
Copilot
AI
Mar 6, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
INSTALL_ARGS is an array, but it’s expanded unquoted (${INSTALL_ARGS[@]+"${INSTALL_ARGS[@]}"}). Unquoted array expansion re-enables word-splitting/globbing and can corrupt arguments (especially --argument if it ever contains whitespace/newlines). Prefer passing the array as "${INSTALL_ARGS[@]}" behind an explicit length check (or always, since the array is initialized).
| ${INSTALL_ARGS[@]+"${INSTALL_ARGS[@]}"} | |
| "${INSTALL_ARGS[@]}" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: Can't we parse and merge this with didc instead?