Skip to content

Refresh xkcd data

Refresh xkcd data #150

Workflow file for this run

name: Refresh xkcd data
on:
schedule:
- cron: '0 0 * * *'
workflow_dispatch:
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version-file: '.nvmrc'
cache: yarn
cache-dependency-path: yarn.lock
- name: Install dependencies
run: yarn install --frozen-lockfile
- name: Download xkcd cache
uses: dawidd6/action-download-artifact@v2
with:
name: xkcd-cache
search_artifacts: true
workflow_conclusion: ""
if_no_artifact_found: warn
- name: Uncompress xkcd cache
run: |
tar_file="xkcd-cache.tar.gz" && \
[ -f "$tar_file" ] && \
tar -xzvf "$tar_file" -C data/raw && \
rm xkcd-cache.tar.gz
exit 0
- name: Run script
env:
TYPESENSE_HOST: ${{ vars.TYPESENSE_HOST }}
TYPESENSE_PORT: ${{ vars.TYPESENSE_PORT }}
TYPESENSE_PROTOCOL: ${{ vars.TYPESENSE_PROTOCOL }}
TYPESENSE_ADMIN_API_KEY: ${{ secrets.TYPESENSE_ADMIN_API_KEY }}
run: |
find data/raw -name "*.html" -type f -exec grep -l "explanation may be incomplete" {} + | xargs -r rm
yarn fetchData
find data/raw -name "*.html" -type f -exec grep -l "server is temporarily unable" {} + | xargs -r rm
find data/raw -name "*.json" -type f -exec grep -l "<html>" {} + | xargs -r rm
yarn refreshData
- name: Compress xkcd cache
if: success() || failure()
run: |
tar -czvf xkcd-cache.tar.gz -C data/raw .
- name: Save xkcd cache
uses: actions/upload-artifact@v3
if: always()
with:
name: xkcd-cache
path: xkcd-cache.tar.gz
if-no-files-found: warn
retention-days: 7