Skip to content

Commit 1bf1687

Browse files
atergaclaude
andauthored
feat: support frontend deployment to Staging B and C (#3706)
## Summary - Map Staging B (`-sb`) to frontend canister `uhh2r-oyaaa-aaaad-agbva-cai`, enabling `./scripts/deploy-pr-to-beta -sb -fe <PR>` - Handle canister not yet installed: when `.config` can't be fetched, fall back to `null` defaults for all fields and prompt the user to provide values instead of erroring out - Updated help text to show both backend and frontend canister IDs per staging environment ## Test plan - [ ] `./scripts/deploy-pr-to-beta -sb -fe -be <PR>` deploys both ends to Staging B - [ ] Frontend args are fetched from the Staging B frontend canister when available - [ ] When the canister isn't installed yet, all fields default to `null` and the user is prompted 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 8eedccd commit 1bf1687

File tree

2 files changed

+51
-40
lines changed

2 files changed

+51
-40
lines changed

scripts/deploy-pr-to-beta

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@ Usage: $0 [--staging-a|-sa | --staging-b|-sb | --staging-c|-sc | --staging <CANI
1010
Select which staging canister to upgrade and which end(s) to deploy.
1111
1212
Options:
13-
--staging-a, -sa Use Staging A (fgte5-ciaaa-aaaad-aaatq-cai)
14-
--staging-b, -sb Use Staging B (jqajs-xiaaa-aaaad-aab5q-cai)
15-
--staging-c, -sc Use Staging C (y2aaj-miaaa-aaaad-aacxq-cai)
13+
--staging-a, -sa Use Staging A (backend: fgte5-ciaaa-aaaad-aaatq-cai, frontend: gjxif-ryaaa-aaaad-ae4ka-cai)
14+
--staging-b, -sb Use Staging B (backend: jqajs-xiaaa-aaaad-aab5q-cai, frontend: uhh2r-oyaaa-aaaad-agbva-cai)
15+
--staging-c, -sc Use Staging C (backend: y2aaj-miaaa-aaaad-aacxq-cai, frontend: uag4f-daaaa-aaaad-agbvq-cai)
1616
--staging <CANISTER_ID> Use the provided canister id
1717
--end <front|back> Which end(s) to deploy (can be specified multiple times)
1818
-fe Shortcut for --end front
@@ -125,8 +125,8 @@ if [ "$DEPLOY_FRONT" = false ] && [ "$DEPLOY_BACK" = false ]; then
125125
exit 1
126126
fi
127127

128-
if [ "$DEPLOY_FRONT" = true ] && [ "$STAGING_NAME" != "a" ]; then
129-
echo "Error: Frontend deployment is not yet supported for Staging B, C, or custom canister IDs. Use --staging-a/-sa for frontend deployment." >&2
128+
if [ "$DEPLOY_FRONT" = true ] && [ "$STAGING_NAME" != "a" ] && [ "$STAGING_NAME" != "b" ] && [ "$STAGING_NAME" != "c" ]; then
129+
echo "Error: Frontend deployment is only supported for Staging A, B, and C. Use --staging-a/-sa, --staging-b/-sb, or --staging-c/-sc." >&2
130130
exit 1
131131
fi
132132

@@ -137,7 +137,14 @@ cd "$ROOT_DIR"
137137
REPO="dfinity/internet-identity"
138138
WORKFLOW_FILE="canister-tests.yml"
139139
WALLET_CANISTER_ID="cvthj-wyaaa-aaaad-aaaaq-cai"
140-
FRONTEND_CANISTER_ID="gjxif-ryaaa-aaaad-ae4ka-cai"
140+
141+
# Map staging environment to its frontend canister ID
142+
case "$STAGING_NAME" in
143+
a) FRONTEND_CANISTER_ID="gjxif-ryaaa-aaaad-ae4ka-cai" ;;
144+
b) FRONTEND_CANISTER_ID="uhh2r-oyaaa-aaaad-agbva-cai" ;;
145+
c) FRONTEND_CANISTER_ID="uag4f-daaaa-aaaad-agbvq-cai" ;;
146+
*) FRONTEND_CANISTER_ID="" ;;
147+
esac
141148

142149
source "$SCRIPTS_DIR/frontend-arg-helpers.bash"
143150

scripts/frontend-arg-helpers.bash

Lines changed: 38 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -44,17 +44,6 @@ build_frontend_install_arg() {
4444
echo " Failed, trying next domain..." >&2
4545
raw_config=""
4646
done
47-
if [ -z "$raw_config" ]; then
48-
echo "Error: Could not fetch config from either $primary_url or $fallback_url" >&2
49-
exit 1
50-
fi
51-
52-
echo ""
53-
echo "Current frontend config:"
54-
echo "$raw_config"
55-
echo ""
56-
echo "Configure install arguments (press Enter to keep each current value):"
57-
5847
# Parse individual fields from the Candid text output.
5948
# For multi-line nested values (analytics_config, related_origins), we extract
6049
# everything from "field = " to the matching closing brace/semicolon.
@@ -82,33 +71,48 @@ build_frontend_install_arg() {
8271
' <<< "$config"
8372
}
8473

85-
local current_backend_canister_id
86-
current_backend_canister_id=$(parse_candid_field "backend_canister_id" "$raw_config")
87-
local current_backend_origin
88-
current_backend_origin=$(parse_candid_field "backend_origin" "$raw_config")
89-
local current_related_origins
90-
current_related_origins=$(parse_candid_field "related_origins" "$raw_config")
91-
local current_fetch_root_key
92-
current_fetch_root_key=$(parse_candid_field "fetch_root_key" "$raw_config")
93-
local current_analytics_config
94-
current_analytics_config=$(parse_candid_field "analytics_config" "$raw_config")
95-
local current_dummy_auth
96-
current_dummy_auth=$(parse_candid_field "dummy_auth" "$raw_config")
97-
local current_dev_csp
98-
current_dev_csp=$(parse_candid_field "dev_csp" "$raw_config")
99-
100-
# All known fields with their defaults (null for missing fields)
74+
# All known fields with their defaults (null for missing/new canisters)
10175
local -a field_names=(backend_canister_id backend_origin related_origins fetch_root_key analytics_config dummy_auth dev_csp)
10276
local -A current_values=(
103-
[backend_canister_id]="$current_backend_canister_id"
104-
[backend_origin]="$current_backend_origin"
105-
[related_origins]="$current_related_origins"
106-
[fetch_root_key]="$current_fetch_root_key"
107-
[analytics_config]="$current_analytics_config"
108-
[dummy_auth]="$current_dummy_auth"
109-
[dev_csp]="$current_dev_csp"
77+
[backend_canister_id]="null"
78+
[backend_origin]="null"
79+
[related_origins]="null"
80+
[fetch_root_key]="null"
81+
[analytics_config]="null"
82+
[dummy_auth]="null"
83+
[dev_csp]="null"
11084
)
11185

86+
if [ -z "$raw_config" ]; then
87+
echo "" >&2
88+
echo "Warning: Could not fetch config from:" >&2
89+
echo " - $primary_url" >&2
90+
echo " - $fallback_url" >&2
91+
echo "The canister may not be installed yet, or there may be a network issue." >&2
92+
echo "All fields will default to null. Please provide values for each field." >&2
93+
read -r -p "Continue with null defaults? [Y/n]: " confirm </dev/tty >&2
94+
if [[ "$confirm" =~ ^[Nn] ]]; then
95+
echo "Aborted by user." >&2
96+
exit 1
97+
fi
98+
else
99+
echo ""
100+
echo "Current frontend config:"
101+
echo "$raw_config"
102+
103+
# Parse current values from the fetched config
104+
for field in "${field_names[@]}"; do
105+
local parsed
106+
parsed=$(parse_candid_field "$field" "$raw_config")
107+
if [ -n "$parsed" ]; then
108+
current_values[$field]="$parsed"
109+
fi
110+
done
111+
fi
112+
113+
echo ""
114+
echo "Configure install arguments (press Enter to keep each current value):"
115+
112116
# Prompt for each field, defaulting empty values to null
113117
local -A final_values
114118
for field in "${field_names[@]}"; do

0 commit comments

Comments
 (0)