Skip to content

Commit

Permalink
Merge pull request #42 from OCHA-DAP/HAPI-131/gha-for-db
Browse files Browse the repository at this point in the history
HAPI-131 GitHub action for database
  • Loading branch information
turnerm authored Oct 11, 2023
2 parents 4e634e4 + b69873e commit ea7231d
Show file tree
Hide file tree
Showing 3 changed files with 61 additions and 1 deletion.
54 changes: 54 additions & 0 deletions .github/workflows/db_export.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
name: Database Export

on:
workflow_dispatch: # Add a run button on GitHub
release:
types:
- published

jobs:
build:
runs-on: ubuntu-latest

services:
postgres:
image: postgres
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
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"

- name: Dump PostgreSQL DB
run: pg_dump -U postgres -Fc hapi -f database/hapi_db.pg_restore

- name: Commit updated DB export
if: always()
uses: stefanzweifel/git-auto-commit-action@v5
with:
file_pattern: database/hapi_db.pg_restore
commit_message: automatic - DB export updated
8 changes: 7 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,13 @@ All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).

## [0.2.3] - 2023-10-11
## [0.4.0] - 2023-10-11

### Added

- GitHub Action to create DB export

## [0.3.0] - 2023-10-11

### Added

Expand Down
Binary file added database/hapi_db.pg_restore
Binary file not shown.

0 comments on commit ea7231d

Please sign in to comment.