Skip to content

Refresh xkcd data

Refresh xkcd data #7

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: Cache data
uses: actions/cache/restore@v3
with:
path: data/raw
key: data-raw
- name: Create .env file
run: |
touch .env
echo TYPESENSE_HOST=${{ env.TYPESENSE_HOST }} >> .env
echo TYPESENSE_PORT=${{ env.TYPESENSE_PORT }} >> .env
echo TYPESENSE_PROTOCOL=${{ env.TYPESENSE_PROTOCOL }} >> .env
echo TYPESENSE_ADMIN_API_KEY=${{ secrets.TYPESENSE_ADMIN_API_KEY }} >> .env
- name: Run script
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: Save cache
if: success() || failure()
uses: actions/cache/save@v3
with:
path: data/raw
key: data-raw