Skip to content

Replikacja PostgresSQL do BigQuery #3

Replikacja PostgresSQL do BigQuery

Replikacja PostgresSQL do BigQuery #3

---
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: "Refresh BI (${{ matrix.environment }})"
runs-on: ubuntu-latest
env:
HEROKU_API_KEY: ${{ secrets.HEROKU_API_KEY }}
COMPOSE_FILE: "docker-compose.dbt.yaml"
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@v0.3.1'
with:
# yamllint disable-line rule:line-length
workload_identity_provider: 'projects/354540873199/locations/global/workloadIdentityPools/github-action-pool/providers/github-action-provider'
service_account: 'pola-bi-github-action@pola-bi.iam.gserviceaccount.com'
export_environment_variables: true
create_credentials_file: true
- 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_export/**'
- run: gsutil rsync /tmp/csv-files/ 'gs://pola_app_pola_backend_postgres_export'
- run: gcloud storage ls --recursive 'gs://pola_app_pola_backend_postgres_export/**'