Backup all comics

This commit is contained in:
Suzanne Soy 2023-11-27 16:28:34 +00:00
parent 160eabce79
commit 53d4698bfd
4 changed files with 64 additions and 4 deletions

View File

@ -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

View File

@ -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

26
_old_index.html Normal file
View File

@ -0,0 +1,26 @@
<!DOCTYPE html>
<html>
<head>
<title>XKCD Archive</title>
<meta charset=utf-8>
<meta name="theme-color" content="#96A8C8">
<link rel="icon" href="./favicon.ico" type="image/x-icon">
<meta name=viewport content="width=device-width,initial-scale=1">
<meta name="robots" content="noindex">
<link rel="stylesheet" href="./styles.css"/>
</head>
<body>
<main>
<h1>XKCD Archive</h1>
<ul>
</ul>
<p>
This is an <a rel="noopener noreferrer" href="https://go.hacdias.com/xkcd-archiver">archival copy</a> of the works
from <a rel="noopener noreferrer" href="https://xkcd.com/">xkcd.com</a>.
</p>
</main>
</body>
</html>

7
concat_htmls.sh Executable file
View File

@ -0,0 +1,7 @@
#!/usr/bin/env bash
set -euET -o pipefail
sed -ne '1,/^ *<\/ul>/p' "$1" | sed -e '/^ *<\/ul>/d'
sed -ne '/^ *<ul>/,/^ *<\/ul>/p' "$2" | sed -e '/^ *<ul>/d; /^ *<\/ul>/d'
sed -ne '/^ *<\/ul>/,$p' "$1"