chore: Support --end <front|back> in PR-to-staging deployment script#3650
chore: Support --end <front|back> in PR-to-staging deployment script#3650
--end <front|back> in PR-to-staging deployment script#3650Conversation
| echo "" | ||
| echo "Configure install arguments (press Enter to keep each current value):" | ||
|
|
||
| # Parse individual fields from the Candid text output. |
There was a problem hiding this comment.
Nit: Can't we parse and merge this with didc instead?
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 1 out of 1 changed files in this pull request and generated 4 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| # 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/ *;$//') |
There was a problem hiding this comment.
The field extraction from raw_config is done via grep ... | sed 's/.*= *//', which strips everything up to the last = on the matched line. If the /.config Candid text is formatted with multiple fields on one line (e.g. record { a = ...; b = ...; }), this will parse the wrong value and can produce an incorrect install argument. Consider parsing by anchoring the regex on the specific field name (capture after backend_canister_id = etc.), or avoid text parsing entirely by decoding into a structured value (e.g. via didc) before prompting.
| # 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') |
| echo "Encoding argument with didc..." | ||
| local encoded | ||
| encoded=$(didc encode \ | ||
| -d ./src/internet_identity_frontend/internet_identity_frontend.did \ | ||
| -t '(InternetIdentityFrontendInit)' \ | ||
| "$candid_arg") |
There was a problem hiding this comment.
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).
| install "$CANISTER_ID" \ | ||
| --mode upgrade \ | ||
| --wasm "$ROOT_DIR/$ARTIFACT_NAME" \ | ||
| ${INSTALL_ARGS[@]+"${INSTALL_ARGS[@]}"} |
There was a problem hiding this comment.
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[@]}" |
| [.workflow_runs[] | ||
| | select(.pull_requests[]?.number == ($PR|tonumber)) | ||
| | select(.path == (".github/workflows/" + $WF)) | ||
| | select(.status == "completed" and .conclusion == "success") |
There was a problem hiding this comment.
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.
Motivation
This is needed due to the recent II canister split. For now, only Staging-A comes with a frontend staging environment, but we could easily add more as needed.
Changes
scripts/deploy-pr-to-betato support the new option--end(mandatory)Tests
./scripts/deploy-pr-to-beta --end front --staging-a 3647