Ingest and Deploy #787
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: Ingest and Deploy | |
on: | |
workflow_dispatch: | |
schedule: | |
# * is a special character in YAML so you have to quote this string | |
- cron: '30 2 * * *' | |
env: | |
DATA_DIR: ./data | |
JSON_OUTPUT_DIR: ./generated_json | |
WEBSITE_DIR: ./website/public | |
jobs: | |
ingest-and-deploy: | |
runs-on: ubuntu-latest | |
container: python:3.10 | |
services: | |
postgres: | |
image: postgres:12-alpine | |
env: | |
POSTGRES_PASSWORD: secret | |
POSTGRES_DB: gadi | |
# Set health checks to wait until postgres has started | |
options: >- | |
--health-cmd pg_isready | |
--health-interval 10s | |
--health-timeout 5s | |
--health-retries 5 | |
steps: | |
- uses: actions/checkout@v2 | |
- name: Install dependencies | |
run: | | |
pip install pipenv | |
pipenv install --dev | |
- name: Set up database | |
run: | | |
pipenv run invoke database.init | |
env: | |
DB_URI: postgresql://postgres:secret@postgres:5432/gadi | |
- name: Cache downloaded data | |
uses: actions/cache@v2 | |
with: | |
path: ${{ env.DATA_DIR }} | |
key: downloaded-files | |
- name: Download laws | |
run: | | |
pipenv run invoke ingest.download-laws $DATA_DIR | |
- name: Ingest data | |
run: | | |
pipenv run invoke ingest.ingest-data $DATA_DIR | |
env: | |
DB_URI: postgresql://postgres:secret@postgres:5432/gadi | |
- name: Generate JSON files | |
run: | | |
pipenv run invoke deploy.generate-static-assets $JSON_OUTPUT_DIR | |
env: | |
DB_URI: postgresql://postgres:secret@postgres:5432/gadi | |
- name: Set up nodejs | |
uses: actions/setup-node@v2 | |
with: | |
node-version: '16' | |
- name: Build static site | |
run: | | |
cd website | |
npm install --dev | |
npm run build | |
- name: Deploy to Netlify | |
uses: nwtgck/[email protected] | |
with: | |
publish-dir: ${{ env.WEBSITE_DIR }} | |
production-branch: main | |
github-token: ${{ secrets.GITHUB_TOKEN }} | |
deploy-message: "Deploy from GitHub Actions" | |
enable-pull-request-comment: false | |
enable-commit-comment: true | |
overwrites-pull-request-comment: true | |
env: | |
NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }} | |
NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID }} |