diff options
Diffstat (limited to 'official-site-scripts/deploy.sh')
| -rwxr-xr-x | official-site-scripts/deploy.sh | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/official-site-scripts/deploy.sh b/official-site-scripts/deploy.sh new file mode 100755 index 0000000..32574e0 --- /dev/null +++ b/official-site-scripts/deploy.sh @@ -0,0 +1,41 @@ +#!/usr/bin/env bash +set -euo pipefail + +REPO_ROOT="$(cd "$(dirname "$0")/.." && pwd)" +[ -f "$REPO_ROOT/.env" ] && set -a && source "$REPO_ROOT/.env" && set +a + +AWS_CLI="${AWS_CLI:-/tmp/awscli/aws/dist/aws}" +APP_ID="d33773t2lyrxkx" +BRANCH="main" +REGION="${AWS_DEFAULT_REGION:-ap-northeast-1}" + +echo "Starting Amplify build: app=$APP_ID branch=$BRANCH" +JOB=$("$AWS_CLI" amplify start-job \ + --app-id "$APP_ID" \ + --branch-name "$BRANCH" \ + --job-type RELEASE \ + --region "$REGION" \ + --output json) + +JOB_ID=$(echo "$JOB" | python3 -c "import json,sys; print(json.load(sys.stdin)['jobSummary']['jobId'])") +echo "Job started: $JOB_ID" +echo "Console: https://ap-northeast-1.console.aws.amazon.com/amplify/apps/$APP_ID/branches/$BRANCH/deployments/$JOB_ID" + +echo "Waiting for build to complete..." +while true; do + STATUS=$("$AWS_CLI" amplify get-job \ + --app-id "$APP_ID" \ + --branch-name "$BRANCH" \ + --job-id "$JOB_ID" \ + --region "$REGION" \ + --output json | python3 -c "import json,sys; print(json.load(sys.stdin)['job']['summary']['status'])") + echo " Status: $STATUS" + if [[ "$STATUS" == "SUCCEED" ]]; then + echo "Build succeeded! https://www.mosquit.one" + break + elif [[ "$STATUS" == "FAILED" || "$STATUS" == "CANCELLED" ]]; then + echo "Build $STATUS" + exit 1 + fi + sleep 15 +done |
