Skip to content

Update database

Update database #17299

Workflow file for this run

name: Update database
on:
push:
branches:
- main
paths:
- .github/workflows/update.yml
schedule:
- cron: 0 * * * *
workflow_dispatch:
repository_dispatch:
types: [build_trigger]
jobs:
update:
name: Update database
runs-on: ubuntu-20.04
steps:
- name: Clone source repo
uses: actions/checkout@v2
with:
repository: PoliNetworkOrg/TheTOLProject
ref: main
- name: Clone database repo
uses: actions/checkout@v2
with:
path: ./data/
- name: Setup Node.js
uses: actions/setup-node@v2
with:
node-version: '16'
- name: Cache dependencies
id: cache
uses: actions/cache@v2
with:
path: ./node_modules
key: modules-${{ hashFiles('package-lock.json') }}
- name: Install dependencies
if: steps.cache.outputs.cache-hit != 'true'
run: npm ci --ignore-scripts
- name: Build local db
run: npm run build:db
env:
GOOGLE_SERVICE_ACCOUNT_EMAIL: ${{ secrets.GOOGLE_SERVICE_ACCOUNT_EMAIL }}
GOOGLE_PRIVATE_KEY: ${{ secrets.GOOGLE_PRIVATE_KEY }}
GOOGLE_DATABASE_SHEET_ID: ${{ secrets.GOOGLE_DATABASE_SHEET_ID }}
- name: Move local db
# There's got to be a better way, but I don't have the mental energy to find it.
run: |
ls temp
mv temp/database.json data/database.json
mv temp/img/** data/img/
cd data
ls
- name: Commit (automatic update)
if: ${{ github.event_name == 'schedule' }}
uses: EndBug/add-and-commit@v7
with:
add: database.json img
cwd: ./data/
author_name: PoliNetwork
author_email: [email protected]
message: '[auto] chore: update database'
pathspec_error_handling: exitImmediately
- name: Commit (manual update)
if: ${{ github.event_name != 'schedule' }}
uses: EndBug/add-and-commit@v7
with:
add: database.json img
cwd: ./data/
message: 'chore: update database'
pathspec_error_handling: exitImmediately