Skip to content

fixup! fixup! fixup! fixup! fixup! fixup! fixup! Copy PostgresSQL to … #6

fixup! fixup! fixup! fixup! fixup! fixup! fixup! Copy PostgresSQL to …

fixup! fixup! fixup! fixup! fixup! fixup! fixup! Copy PostgresSQL to … #6

---
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'
- name: Checkout actions-oidc-debugger
uses: actions/checkout@v3
with:
repository: github/actions-oidc-debugger
ref: main
path: ./.github/actions/actions-oidc-debugger
- name: Debug OIDC Claims
uses: github/actions-oidc-debugger
with:
audience: 'https://github.com/github'
- 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/**'