fix: homepage is skate-spots.org (not .com) + skip no-op deploys
The package.json homepage pointed at skate-spots.com — a different domain on a different host, not this app. Also adds a deploy guard: auto-deploy.sh now hashes exactly what would be uploaded (dist/ + netlify/ + netlify.toml) and skips the Netlify deploy when it is byte-identical to what is already live, so metadata-only commits (version bumps, homepage) stop costing 15 credits.
This commit is contained in:
parent
356e4d5c95
commit
40799e1453
2 changed files with 23 additions and 2 deletions
|
|
@ -3,7 +3,7 @@
|
||||||
"private": true,
|
"private": true,
|
||||||
"version": "1.5.4",
|
"version": "1.5.4",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"homepage": "https://skate-spots.com",
|
"homepage": "https://skate-spots.org",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "npm i --silent && vite",
|
"dev": "npm i --silent && vite",
|
||||||
"build": "npm i --silent && vite build -l error && cp dist/index.html dist/404.html && echo 'Project built successfully!'",
|
"build": "npm i --silent && vite build -l error && cp dist/index.html dist/404.html && echo 'Project built successfully!'",
|
||||||
|
|
|
||||||
|
|
@ -24,6 +24,7 @@ STATE_DIR="$HOME/.local/state/skatespots-deploy"
|
||||||
SHA_FILE="$STATE_DIR/last-deployed-sha"
|
SHA_FILE="$STATE_DIR/last-deployed-sha"
|
||||||
LOCK_FILE="$STATE_DIR/last-lock-hash"
|
LOCK_FILE="$STATE_DIR/last-lock-hash"
|
||||||
INTERVAL_FILE="$STATE_DIR/last-deploy-epoch"
|
INTERVAL_FILE="$STATE_DIR/last-deploy-epoch"
|
||||||
|
DIST_HASH_FILE="$STATE_DIR/last-dist-hash"
|
||||||
mkdir -p "$STATE_DIR"
|
mkdir -p "$STATE_DIR"
|
||||||
|
|
||||||
# Production deploys cost 15 Netlify credits each, and this timer polls every
|
# Production deploys cost 15 Netlify credits each, and this timer polls every
|
||||||
|
|
@ -125,10 +126,30 @@ if ! node scripts/smoke-test.mjs; then
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# 7. Deploy to Netlify production.
|
# 7. Skip the deploy entirely when the upload would be byte-identical to what is
|
||||||
|
# already live. Metadata-only changes (a package.json version/homepage, a dep
|
||||||
|
# bump that doesn't alter the bundle) otherwise burn a 15-credit production
|
||||||
|
# deploy for nothing. The snapshot covers exactly what `netlify deploy
|
||||||
|
# --dir=dist` uploads: dist/, netlify/ (functions) and netlify.toml.
|
||||||
|
snapshot_hash() {
|
||||||
|
{
|
||||||
|
find dist -type f -print0 2>/dev/null | sort -z | xargs -0 -r sha256sum
|
||||||
|
if [ -d netlify ]; then find netlify -type f -print0 | sort -z | xargs -0 -r sha256sum; fi
|
||||||
|
if [ -f netlify.toml ]; then sha256sum netlify.toml; fi
|
||||||
|
} | sha256sum | awk '{print $1}'
|
||||||
|
}
|
||||||
|
DIST_HASH="$(snapshot_hash)"
|
||||||
|
if [ -f "$DIST_HASH_FILE" ] && [ "$DIST_HASH" = "$(cat "$DIST_HASH_FILE")" ]; then
|
||||||
|
log "build output is unchanged from the live deploy — skipping Netlify (no credits spent)"
|
||||||
|
echo "$REMOTE_SHA" > "$SHA_FILE"
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
# 7b. Deploy to Netlify production.
|
||||||
log "deploying to Netlify…"
|
log "deploying to Netlify…"
|
||||||
netlify deploy --prod --dir=dist
|
netlify deploy --prod --dir=dist
|
||||||
|
|
||||||
echo "$REMOTE_SHA" > "$SHA_FILE"
|
echo "$REMOTE_SHA" > "$SHA_FILE"
|
||||||
|
echo "$DIST_HASH" > "$DIST_HASH_FILE"
|
||||||
date +%s > "$INTERVAL_FILE"
|
date +%s > "$INTERVAL_FILE"
|
||||||
log "deployed ${REMOTE_SHA:0:9} ✓"
|
log "deployed ${REMOTE_SHA:0:9} ✓"
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue