name: update XKCD archive on: # Runs on pushes targeting the default branch push: branches: ["main"] schedule: - cron: "0 0 * * *" # Allows you to run this workflow manually from the Actions tab workflow_dispatch: permissions: contents: read pages: write id-token: write concurrency: group: "pages" cancel-in-progress: false jobs: updatexkcd: environment: name: github-pages url: ${{ steps.deployment.outputs.page_url }} runs-on: ubuntu-latest steps: - name: Checkout 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: Previously downloaded until run: echo $(cd result/www; (echo 1; for i in [0-9]*; do echo $i; done) | sort --general-numeric-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 30 run: go run . result/www -f $(( 1 + $( cd result/www; (echo 1; for i in [0-9]*; do echo $i; done) | sort --general-numeric-sort | tail -n 1) )) -t 2400 # go run . output-dir -f from -t to - name: concat index.html run: ./concat_htmls.sh result/www/index.html _old_index.html > _new_index.html; mv _new_index.html result/www/index.html - name: Now downloaded until run: echo $(cd result/www; (echo 1; for i in [0-9]*; do echo $i; done) | sort --general-numeric-sort | tail -n 1) # - 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 $(cd result/www; (echo 1; for i in [0-9]*; do echo $i; done) | sort --general-numeric-sort | tail -n 1) -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 uses: actions/upload-pages-artifact@v2 with: # Upload entire repository path: 'result/www' - name: Deploy to GitHub Pages id: deployment uses: actions/deploy-pages@v2 - name: Download IPFS run: ./.github/github_install_ipfs.sh - name: Print IPFS hash run: PATH="/tmp/kubo:$PATH" ipfs cid base32 "$(ipfs add --ignore-rules-path "result/www/.ipfsignore" --pin=false --hidden -Qr "result/www/")" - name: Upload to IPFS run: PATH="/tmp/kubo:$PATH" ./.github/pin-using-ipfs.sh continue-on-error: true env: IPFS_SWARM_CONNECT_TO: ${{ secrets.IPFS_SWARM_CONNECT_TO }} IPFS_REMOTE_API_ENDPOINT: ${{ secrets.IPFS_REMOTE_API_ENDPOINT }} IPFS_REMOTE_TOKEN: ${{ secrets.IPFS_REMOTE_TOKEN }} - name: Install OVH pip package run: pip install ovh - name: Update OVH _dnslink run: export PATH="/tmp/kubo:$PATH"; export IPFS_HASH="$(ipfs cid base32 "$(ipfs add --ignore-rules-path "result/www/.ipfsignore" --pin=false --hidden -Qr "result/www/")")"; python ./.github/update-ovh.py >/dev/null 2>&1 env: API_OVH_APPLICATION_KEY: ${{ secrets.API_OVH_APPLICATION_KEY }} API_OVH_APPLICATION_SECRET: ${{ secrets.API_OVH_APPLICATION_SECRET }} API_OVH_CONSUMER_KEY: ${{ secrets.API_OVH_CONSUMER_KEY }} API_OVH_ENDPOINT: ${{ secrets.API_OVH_ENDPOINT }} OVH_DNS_DOMAIN: ${{ secrets.OVH_DNS_DOMAIN }} OVH_DNS_RECORD_ID: ${{ secrets.OVH_DNS_RECORD_ID }} - name: Warm up IPFS gateway caches run: PATH="/tmp/kubo:$PATH" ./.github/warm-up-gateway-caches.sh - name: Update homepage URL run: PATH="/tmp/kubo:$PATH" ./.github/github_update_homepage.sh env: API_TOKEN_FOR_UPDATE_HOMEPAGE: ${{ secrets.API_TOKEN_FOR_UPDATE_HOMEPAGE }}