Skip to content

Database Export

Database Export #35

Workflow file for this run

name: Database Export
on:
workflow_dispatch: # Add a run button on GitHub
push:
tags:
- "*"
jobs:
build:
runs-on: ubuntu-latest
services:
postgres:
image: postgres:14-alpine
env:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
POSTGRES_DB: hapi
ports:
- 5432:5432
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
--name postgres-container
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: 3.11
- name: Install dependencies
run: |
pip install --upgrade pip
pip install -r requirements.txt
pip install .
- name: Run Pipeline
run: python3.11 -m hapi.pipelines.app -db "postgresql+psycopg://postgres:postgres@localhost:5432/hapi"
env:
HDX_KEY: ${{ secrets.HDX_BOT_SCRAPERS_API_TOKEN }}
- name: Dump PostgreSQL DB
run: |
mkdir database
docker exec -t postgres-container pg_dump -U postgres -Fc hapi -f hapi_db.pg_restore
docker cp postgres-container:/hapi_db.pg_restore database/hapi_db.pg_restore
docker exec -t postgres-container psql -d hapi -c "copy(select * from operational_presence_view) TO 'operational_presence.csv' (FORMAT csv, DELIMITER ',', HEADER);"
docker cp postgres-container:/operational_presence.csv database/operational_presence.csv
- name: Commit updated DB export
uses: JamesIves/github-pages-deploy-action@v4
with:
branch: db-export
folder: database
target-folder: database