From 53d4698bfde1a804b3e2ec2cddc8e37947bbf4d4 Mon Sep 17 00:00:00 2001 From: Suzanne Soy Date: Mon, 27 Nov 2023 16:28:34 +0000 Subject: [PATCH] Backup all comics --- .github/pin-using-ipfs.sh | 2 +- .github/workflows/cron.yml | 33 ++++++++++++++++++++++++++++++--- _old_index.html | 26 ++++++++++++++++++++++++++ concat_htmls.sh | 7 +++++++ 4 files changed, 64 insertions(+), 4 deletions(-) create mode 100644 _old_index.html create mode 100755 concat_htmls.sh diff --git a/.github/pin-using-ipfs.sh b/.github/pin-using-ipfs.sh index b84a129..892f7e5 100755 --- a/.github/pin-using-ipfs.sh +++ b/.github/pin-using-ipfs.sh @@ -41,7 +41,7 @@ if test -n "${IPFS_REMOTE_API_ENDPOINT:-}" && test -n "${IPFS_REMOTE_TOKEN:-}" & printf "Pinning %s on the remote service %s...\n" "$h" "$i" ( - if ipfs pin remote add --service=my-remote-pin-"$i" --name="site-bounties-$(TZ=UTC git log -1 --format=%cd --date=iso-strict-local HEAD)-$GITHUB_SHA" "$h"; then + if ipfs pin remote add --service=my-remote-pin-"$i" --name="xkcd-$(TZ=UTC git log -1 --format=%cd --date=iso-strict-local HEAD)-$GITHUB_SHA" "$h"; then echo $? > ipfs-pin-remote-add-exitcode else echo $? > ipfs-pin-remote-add-exitcode diff --git a/.github/workflows/cron.yml b/.github/workflows/cron.yml index da16fac..64e56a7 100644 --- a/.github/workflows/cron.yml +++ b/.github/workflows/cron.yml @@ -30,18 +30,45 @@ jobs: uses: actions/checkout@v3 with: submodules: 'recursive' + - name: Download artifact + id: download-artifact + uses: dawidd6/action-download-artifact@v2 + with: + workflow: cron.yml + workflow_conclusion: success + path: old + - name: Make output dir + run: mkdir -p result/www +# - name: extract +# run: tar -C result/www -xf ./old/github-pages/artifact.tar; find result - name: Go install run: go install . - - name: Make output dir - run: mkdir result/ + - name: Previously downloaded until + run: echo $(cd result/www; (echo 1; for i in [0-9]*; do echo $i; done) | sort | tail -n 1) +# - name: Copy old index +# run: cp result/www/index.html _old_index.html - name: Go run - run: go run . result/www -f 1 -t 5 + run: go run . result/www -f 1 -t 30 +# run: go run . result/www -f $(( 1 + $( cd result/www; (echo 1; for i in [0-9]*; do echo $i; done) | sort | tail -n 1) )) -t 30 + # go run . output-dir -f from -t to + - name: concat index.html + run: ./concat_htmls.sh _old_index.html result/www/index.html > _new_index.html; mv _new_index.html result/www/index.html + - name: find + run: find result - name: create .ipfsignore run: touch result/www/.ipfsignore - name: create .nojekyll run: touch result/www/.nojekyll - name: create ipfs-add.sh run: cp _ipfs-add.sh result/www/ipfs-add.sh; (cd result/www; find 3 -type f > ../../.github/files-to-cache.lst) +# - name: git push +# run: | +# git config --global user.name 'Suzanne Soy' +# git config --global user.email 'suzannesoy@users.noreply.github.com' +# git remote set-url origin https://x-access-token:${{ secrets.PAT }}@github.com/${{ github.repository }} +# git add result +# git commit -m "Updated comics" +# git push - name: Setup Pages uses: actions/configure-pages@v3 - name: Upload artifact diff --git a/_old_index.html b/_old_index.html new file mode 100644 index 0000000..ce1f323 --- /dev/null +++ b/_old_index.html @@ -0,0 +1,26 @@ + + + + + XKCD Archive + + + + + + + + +
+

XKCD Archive

+ +

+ This is an archival copy of the works + from xkcd.com. +

+
+ + + diff --git a/concat_htmls.sh b/concat_htmls.sh new file mode 100755 index 0000000..6c300e4 --- /dev/null +++ b/concat_htmls.sh @@ -0,0 +1,7 @@ +#!/usr/bin/env bash + +set -euET -o pipefail + +sed -ne '1,/^ *<\/ul>/p' "$1" | sed -e '/^ *<\/ul>/d' +sed -ne '/^ *