Skip to content

Import and export schemas #434

Import and export schemas

Import and export schemas #434

name: Import and export schemas
on:
schedule:
- cron: '0 0 * * *'
workflow_dispatch:
jobs:
import_export_libraries:
runs-on: ubuntu-latest
env:
PGDATABASE: ${{ secrets.PGDATABASE }}
PGPASSWORD: ${{ secrets.PGPASSWORD }}
PGPORT: 5432
PGUSER: ${{ secrets.PGUSER }}
PGHOST: ${{ secrets.PGHOST }}
steps:
- uses: actions/checkout@v2
- name: Install PostgreSQL client
run: |
sudo apt-get update
sudo apt-get install --yes postgresql-client
- name: Refresh authentication
run: psql -f import_authentication.sql
- name: Combine libraries
run: awk '(NR == 1) || (FNR > 1)' ./data/schemas/libraries/*.csv > ./data/schemas/libraries.csv
- name: Remove carriage returns
run: sed -i 's/\r//g' ./data/schemas/libraries.csv
- name: Import libraries
run: psql -f import_libraries.sql
- name: Export libraries
run: psql -f export_libraries.sql
- name: Set up Python
uses: actions/setup-python@v1
with:
python-version: '3.x'
- name: Split library files
run: python3 ./scripts/split_libraries.py
- name: check for changes
run: git status
- name: commit changed files
run: |
git config --local user.email "action@github.com"
git config --local user.name "GitHub Action"
git add .
git diff-index --quiet HEAD || git commit -m "Auto export of libraries"
- name: fetch from main
run: git fetch --no-tags --prune --depth=1 origin +refs/heads/*:refs/remotes/origin/*
- name: push code to main
run: git push origin HEAD:main