diff --git a/.gitea/workflows/deploy.yml b/.gitea/workflows/deploy.yml index 5d52f37..48ac93c 100644 --- a/.gitea/workflows/deploy.yml +++ b/.gitea/workflows/deploy.yml @@ -57,39 +57,61 @@ jobs: - name: Verify build output run: test -f dist/index.html - # Publish dist/index.html to the WebDAV mirror. The pretty URL - # (…/weather/index.html) 401s without auth; the file is the full - # www/static/weather/index.html path with basic auth. + # Publish index.html + PWA companion files (manifest, service worker, + # icons) to the WebDAV mirror. The pretty URL (…/weather/index.html) 401s + # without auth; files live at www/static/weather/ with basic auth. - name: Publish to WebDAV (/weather) env: WEBDAV_USER: ${{ secrets.WEBDAV_USER }} WEBDAV_PASS: ${{ secrets.WEBDAV_PASS }} - WEBDAV_URL: https://files.thecookiejar.me/www/static/weather/index.html + WEBDAV_BASE: https://files.thecookiejar.me/www/static/weather run: | + set -e if [ -z "$WEBDAV_USER" ] || [ -z "$WEBDAV_PASS" ]; then echo "::error::WEBDAV_USER / WEBDAV_PASS repo secrets are not set." echo "::error::Add them under Settings → Actions → Secrets, then re-run this job." exit 1 fi - # DELETE-then-PUT: the serving layer caches uploaded files, so a plain - # PUT over an existing file returns 201 but keeps serving the OLD copy. - # Deleting first guarantees the new build is actually served. (Each curl - # is a single line -- YAML block scalars don't convert backslash-nl.) - curl -sS -u "$WEBDAV_USER:$WEBDAV_PASS" -X DELETE "$WEBDAV_URL" || echo "(DELETE returned non-zero; file may not exist yet -- continuing)" - curl -sS --fail -u "$WEBDAV_USER:$WEBDAV_PASS" -X PUT -T dist/index.html -H 'Content-Type: text/html' "$WEBDAV_URL" - echo "Published to $WEBDAV_URL" + publish() { + local src="$1" dst="$2" ctype="$3" + # DELETE-then-PUT: the serving layer caches uploaded files, so a plain + # PUT over an existing file keeps serving the OLD copy. + curl -sS -u "$WEBDAV_USER:$WEBDAV_PASS" -X DELETE "$dst" || echo "(DELETE non-zero; may be a new file -- continuing)" + curl -sS --fail -u "$WEBDAV_USER:$WEBDAV_PASS" -X PUT -T "$src" -H "Content-Type: $ctype" "$dst" + echo "Published $src -> $dst" + } + # Ensure the icons/ subfolder exists (PUT into a missing dir can 409/404 + # depending on server). MKCOL returns 405 if it already exists — fine. + curl -sS -u "$WEBDAV_USER:$WEBDAV_PASS" -X MKCOL "$WEBDAV_BASE/icons" -o /dev/null || echo "(icons dir exists or MKCOL unsupported -- continuing)" + publish dist/index.html "$WEBDAV_BASE/index.html" 'text/html' + publish dist/manifest.webmanifest "$WEBDAV_BASE/manifest.webmanifest" 'application/manifest+json' + publish dist/sw.js "$WEBDAV_BASE/sw.js" 'application/javascript; charset=utf-8' + publish dist/icons/icon-192.png "$WEBDAV_BASE/icons/icon-192.png" 'image/png' + publish dist/icons/icon-512.png "$WEBDAV_BASE/icons/icon-512.png" 'image/png' + publish dist/icons/icon-maskable-512.png "$WEBDAV_BASE/icons/icon-maskable-512.png" 'image/png' - # Pull the freshly uploaded file back and compare it to our build, so a - # successful deploy isn't just "curl returned 0" but bytes actually match. - - name: Verify deployed file matches build + # Pull the freshly uploaded files back and compare bytes, so a successful + # deploy isn't just "curl returned 0" but the served copy actually matches. + - name: Verify deployed files match build env: WEBDAV_USER: ${{ secrets.WEBDAV_USER }} WEBDAV_PASS: ${{ secrets.WEBDAV_PASS }} - WEBDAV_URL: https://files.thecookiejar.me/www/static/weather/index.html + WEBDAV_BASE: https://files.thecookiejar.me/www/static/weather run: | - curl -sS --fail -u "$WEBDAV_USER:$WEBDAV_PASS" "$WEBDAV_URL" -o /tmp/deployed.html - sha1sum dist/index.html /tmp/deployed.html - test "$(sha1sum dist/index.html | cut -d' ' -f1)" = \ - "$(sha1sum /tmp/deployed.html | cut -d' ' -f1)" \ - && echo "Deploy verified: bytes match" \ - || { echo "::error::Deployed file does not match build"; exit 1; } + set -e + verify() { + local src="$1" dst="$2" + curl -sS --fail -u "$WEBDAV_USER:$WEBDAV_PASS" "$dst" -o "/tmp/deployed_$(basename "$src")" + sha1sum "$src" "/tmp/deployed_$(basename "$src")" + test "$(sha1sum "$src" | cut -d' ' -f1)" = \ + "$(sha1sum "/tmp/deployed_$(basename "$src")" | cut -d' ' -f1)" \ + || { echo "::error::Deployed $src does not match build"; exit 1; } + echo "Verified $src bytes match" + } + verify dist/index.html "$WEBDAV_BASE/index.html" + verify dist/manifest.webmanifest "$WEBDAV_BASE/manifest.webmanifest" + verify dist/sw.js "$WEBDAV_BASE/sw.js" + verify dist/icons/icon-192.png "$WEBDAV_BASE/icons/icon-192.png" + verify dist/icons/icon-512.png "$WEBDAV_BASE/icons/icon-512.png" + verify dist/icons/icon-maskable-512.png "$WEBDAV_BASE/icons/icon-maskable-512.png" + echo "All deployed files verified" diff --git a/dist/icons/icon-192.png b/dist/icons/icon-192.png new file mode 100644 index 0000000..017c321 Binary files /dev/null and b/dist/icons/icon-192.png differ diff --git a/dist/icons/icon-512.png b/dist/icons/icon-512.png new file mode 100644 index 0000000..7cb962f Binary files /dev/null and b/dist/icons/icon-512.png differ diff --git a/dist/icons/icon-maskable-512.png b/dist/icons/icon-maskable-512.png new file mode 100644 index 0000000..d5da42a Binary files /dev/null and b/dist/icons/icon-maskable-512.png differ diff --git a/dist/index.html b/dist/index.html index 4aa7e73..ef95e00 100644 --- a/dist/index.html +++ b/dist/index.html @@ -2,8 +2,15 @@ - + + + + + + + + WeatherLens