Source identity
| Field | Recorded value |
|---|---|
| Source type | GitHub source |
| Original record | Janady13/missionmatch / scripts/deploy.sh |
| Date | Not specified in source |
| Repository | Janady13/missionmatch |
| Revision | 720d47fae476b0d38477ae4401697d372b1ea2bc |
| Branch | feature/opportunity-to-outcome |
| Path or archive member | scripts/deploy.sh |
| Original SHA-256 | 079891bbe4379ed9979b5610451cdddb3f4782ddbe404d9198e8294c830fc061 |
| Git blob SHA | 916b0a045a2985eb0b91db1aa81168ecfad98f43 |
| Reading-copy SHA-256 | 079891bbe4379ed9979b5610451cdddb3f4782ddbe404d9198e8294c830fc061 |
Every recorded occurrence
These 2 records contain identical original source bytes. Their paths and revisions remain part of the archive.
| Original record | Branch or archive | Revision / identifier | Original location |
|---|---|---|---|
| Janady13/missionmatch / scripts/deploy.sh | feature/opportunity-to-outcome | 720d47fae476b0d38477ae4401697d372b1ea2bc | Open original |
| Janady13/missionmatch / scripts/deploy.sh | feature/aioe-upgrade | 2178e7298d0e5d9af83afa12402fd587f0ba6ed8 | Open original |
Recovered source transcript
Download complete source text ↓79 lines · 3.4 KB
#!/usr/bin/env bash
# Deploys missionMATCH to Bubbles: gates, migrations, API binary, then the SPA bundle.
#
# Written because the same sequence was run by hand a dozen times across this program, and three of its
# steps have a failure mode that is SILENT if you skip them:
#
# 1. scp over a RUNNING binary fails with ETXTBSY. The service then restarts on the OLD build and
# healthz returns 200 the entire time, so the deploy looks successful and is not. The binary is
# staged, its sha256 compared to the local one, and the service stopped before the swap.
# 2. The live index.html carries injected SEO lines the build output does not have. Overwriting it
# deletes them silently, so only the two asset hashes are rewritten in place and the count is
# checked afterwards.
# 3. The API takes about five seconds to boot because it verifies the stored embedding model on
# startup, so a health check fired immediately reports a false failure.
set -euo pipefail
HOST="${MM_HOST:-user@100.90.97.104}"
API_PATH="${MM_API_PATH:-/home/user/missionmatch/mm-api}"
WEB_ROOT="${MM_WEB_ROOT:-/var/www/sites/missionmatch}"
MIGRATOR_DSN="${MIGRATOR_DSN:-}"
ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
cd "$ROOT"
say() { printf '\n=== %s ===\n' "$1"; }
say "gates"
go build ./...
go vet ./... >/dev/null
go test ./... >/dev/null
make ci-gates
if [ -n "$MIGRATOR_DSN" ]; then
say "migrations"
goose -dir db/migrations postgres "$MIGRATOR_DSN" up
else
echo "MIGRATOR_DSN unset, skipping migrations" >&2
fi
say "api"
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 GOFIPS140=v1.0.0 go build -trimpath -o /tmp/mm-api ./cmd/api
LOCAL=$(shasum -a 256 /tmp/mm-api | awk '{print $1}')
scp -q /tmp/mm-api "$HOST:/tmp/mm-api.new"
ssh "$HOST" "
REMOTE=\$(sha256sum /tmp/mm-api.new | awk '{print \$1}')
[ \"\$REMOTE\" = '$LOCAL' ] || { echo 'sha256 mismatch, aborting'; exit 1; }
echo user | sudo -S -p '' systemctl stop mm-api
mv /tmp/mm-api.new '$API_PATH' && chmod 755 '$API_PATH'
echo user | sudo -S -p '' systemctl start mm-api
"
echo "waiting for boot"
CODE=""
for i in $(seq 1 20); do
CODE=$(ssh "$HOST" "curl -s -o /dev/null -w '%{http_code}' http://127.0.0.1:8094/healthz" || true)
if [ "$CODE" = "200" ]; then echo "healthy after ${i}s"; break; fi
sleep 1
done
[ "$CODE" = "200" ] || { echo "the API did not become healthy"; exit 1; }
say "frontend"
# npm run build is tsc -b && vite build. tsc -b is the REAL typecheck: this repo uses a solution style
# tsconfig, so a bare "tsc --noEmit" silently checks nothing at all.
( cd frontend && npm run build )
NEWJS=$(grep -oE 'assets/index-[A-Za-z0-9_.-]+\.js' frontend/dist/index.html | head -1 | sed 's|assets/||')
NEWCSS=$(grep -oE 'assets/index-[A-Za-z0-9_.-]+\.css' frontend/dist/index.html | head -1 | sed 's|assets/||')
tar czf /tmp/mm-assets.tgz -C frontend/dist assets
scp -q /tmp/mm-assets.tgz "$HOST:/tmp/mm-assets.tgz"
ssh "$HOST" "
set -e
echo user | sudo -S -p '' -v
sudo cp '$WEB_ROOT/index.html' '$WEB_ROOT/index.html.bak.\$(date +%s)'
sudo tar xzf /tmp/mm-assets.tgz -C '$WEB_ROOT/'
sudo sed -i -E 's|assets/index-[A-Za-z0-9_.-]+\.js|assets/$NEWJS|g; s|assets/index-[A-Za-z0-9_.-]+\.css|assets/$NEWCSS|g' '$WEB_ROOT/index.html'
rm -f /tmp/mm-assets.tgz
SEO=\$(grep -c 'canonical\|og:title\|og:type\|og:url\|twitter:card' '$WEB_ROOT/index.html')
[ \"\$SEO\" -ge 5 ] || { echo \"SEO lines lost (\$SEO of 5), restore the backup beside index.html\"; exit 1; }
echo \"SEO lines intact: \$SEO\"
"
say "done"