Skip to content

Replikacja PostgresSQL do BigQuery #15

Replikacja PostgresSQL do BigQuery

Replikacja PostgresSQL do BigQuery #15

---
name: Transfer PostgresSQL to GCS
on:
workflow_dispatch:
inputs:
heroku_app:
description: 'Heroku app name[pola-app/pola-staging]'
required: true
default: 'pola-app'
# TODO: !!! Remove before merging !!!!!
pull_request:
branches: ['master']
permissions:
id-token: write # This is required for requesting the JWT
contents: read # This is required for actions/checkout
env:
GITHUB_REPOSITORY: ${{ github.repository }}
GITHUB_ORGANIZATION: ${{ github.repository_owner }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# HEROKU_APP: ${{ github.event.inputs.heroku_app }}
jobs:
deploy-bi:
# strategy:
# fail-fast: false
# matrix:
# environment: [prod, staging]
name: "Transfer PostgresSQL to GCS"
runs-on: ubuntu-latest
env:
HEROKU_API_KEY: ${{ secrets.HEROKU_API_KEY }}
steps:
- name: "Checkout ${{ github.ref }} ( ${{ github.sha }} )"
uses: actions/checkout@v4
with:
fetch-depth: 2
# Use Open ID Connect to authenticate to GCP
# For details, see:
# https://cloud.google.com/blog/products/identity-security/enabling-keyless-authentication-from-github-actions
- id: 'auth'
name: 'Authenticate to GCP'
uses: 'google-github-actions/auth@v2'
with:
project_id: 'pola-bi-looker'
# yamllint disable-line rule:line-length
workload_identity_provider: 'projects/354540873199/locations/global/workloadIdentityPools/github/providers/pola-backend-repo'
export_environment_variables: true
create_credentials_file: true
- name: 'Set up Cloud SDK'
uses: 'google-github-actions/setup-gcloud@v2'
- run: gcloud auth list --filter=status:ACTIVE --format="value(account)"
- name: "Setup Python"
uses: actions/setup-python@v5
with:
python-version: '3.9'
- name: "Set environment env variable"
run: |-
pip install django-environ
source <(python ./pola-bi/dev.py --environment "prod")
printenv | grep POLA_APP | cut -d "=" -f 2- | xargs -n 1 -I {} echo "::add-mask::{}"
printenv | grep POLA_APP >> $GITHUB_ENV;
- run: ./pola-bi/postgres_to_gcs/postgres_to_csv.py --output-dir /tmp/csv-files/
- run: find /tmp/csv-files/
- run: gcloud storage ls --recursive "gs://pola-app_pola-backend_postgres_csv-files"
- run: gsutil rsync /tmp/csv-files/ "gs://pola-app_pola-backend_postgres_csv-files"
- run: gcloud storage ls --recursive "gs://pola-app_pola-backend_postgres_csv-files"
- run: ./pola-bi/postgres_to_gcs/gcs_to_bigquery.py