From 6c9d11f03522f263133a77655445fd6a8e3585f0 Mon Sep 17 00:00:00 2001 From: bel Date: Sun, 15 Oct 2023 07:25:13 -0600 Subject: [PATCH] change all ttf fonts to woff2 and replace in public --- .harness/firebase-deploy.yaml | 6 +++--- deploy.firebase.sh | 24 ++++++++++++++++++++++++ 2 files changed, 27 insertions(+), 3 deletions(-) diff --git a/.harness/firebase-deploy.yaml b/.harness/firebase-deploy.yaml index becfa7a..3cb1072 100644 --- a/.harness/firebase-deploy.yaml +++ b/.harness/firebase-deploy.yaml @@ -38,7 +38,7 @@ spec: when: build.event == "push" && build.target == "main" spec: name: build - container: + container: image: andreysenov/firebase-tools user: root envs: @@ -46,5 +46,5 @@ spec: GITLAB_PAT: ${{ secrets.get("resume-gitlab-gitlab-breel-dev-token") }} shell: sh script: | - apt -y install git - bash ./deploy.firebase.sh \ No newline at end of file + apt -y install git woff2 + bash ./deploy.firebase.sh diff --git a/deploy.firebase.sh b/deploy.firebase.sh index 38cf12b..3134eb4 100755 --- a/deploy.firebase.sh +++ b/deploy.firebase.sh @@ -4,6 +4,7 @@ set -o pipefail set -e set -u + if tty && ! which firebase; then f="$(mktemp)" wget https://firebase.tools -O - > "$f" @@ -24,6 +25,29 @@ cp ./open-resume.com.d/resume.html.2 $outdir/public/index.html cp ./open-resume.com.d/resume.pdf $outdir/public/BreeLaPointeResume.pdf cp -r ./open-resume.com.d/fonts $outdir/public/ +( + if ! which woff2_compress; then + sudo apt -y install woff2 + fi + set -ueo pipefail + for f in "$outdir"/public/fonts/*.ttf; do + echo ttf to woff2 for "$f" + if [ -f "$f" ]; then + woff2_compress "$f" + rm "$f" + fi + basename_f="${f##*/}" + find "$outdir/public" -type f | grep -v public.fonts | while read -r f2; do + sed -i "s#$basename_f#${basename_f%.ttf}.woff2#g" "$f2" + done + echo asserting no $basename_f + ! grep -R "$basename_f" "$outdir/public" + echo asserting ${basename_f%.ttf}.woff2 + grep -R "${basename_f%.ttf}.woff2" "$outdir/public" + done + du -sh "$outdir/public/fonts/"* +) + cp -r ./firebase.json ./.firebaserc ./.firebase $outdir/ sed -i "s#deploy/public#public#" $outdir/firebase.json cd $outdir