Rebuild with fresh data #859
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Rebuild with fresh data | |
on: | |
repository_dispatch: | |
workflow_dispatch: | |
schedule: | |
# every day at 4am (PDT, GMT-7) | |
# cron times use UTC | |
- cron: 0 11 * * * | |
jobs: | |
run: | |
runs-on: ubuntu-latest | |
timeout-minutes: 5 | |
steps: | |
- name: Checkout repo | |
uses: actions/checkout@v3 | |
with: | |
ref: main | |
- name: Setup Bun Runtime | |
uses: antongolub/action-setup-bun@v1 | |
with: | |
bun-version: 0.7.3 | |
- name: Install dependencies | |
run: bun install | |
- name: Fetch the JSON files | |
run: bun run fetch | |
- name: Build the website | |
run: bun run build | |
- name: Remove dist/ from .gitignore | |
run: sed -i '/^dist\/$/d' .gitignore | |
- name: Push changes to "build" branch | |
run: | | |
git config user.name "${{ github.actor }}" | |
git config user.email "${{ github.actor }}@users.noreply.github.com" | |
git checkout -b build | |
git add . | |
git commit -m "built at $(date +"%Y.%m.%d")" | |
git push -f origin build | |
- name: Archive data in Cloudflare R2 | |
run: | | |
FILENAME="data_$(date -Iseconds).json.zst" | |
zstd src/json/data.json -o "$FILENAME" | |
aws s3 cp "$FILENAME" "s3://bcliquor/$FILENAME" | |
env: | |
AWS_ACCESS_KEY_ID: ${{ secrets.R2_ACCESS_KEY_ID }} | |
AWS_SECRET_ACCESS_KEY: ${{ secrets.R2_SECRET_ACCESS_KEY }} | |
AWS_DEFAULT_REGION: auto | |
AWS_ENDPOINT_URL: https://${{ secrets.R2_ACCOUNT_ID }}.r2.cloudflarestorage.com |