Skip to content

Commit

Permalink
fix populate parameter (#153)
Browse files Browse the repository at this point in the history
  • Loading branch information
davidgamez authored Nov 3, 2023
1 parent fdcea7a commit bd7357b
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 14 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/db-update-dev.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Update the Mobility Database Schema
name: Dev Database Update
name: Database Update - DEV
on:
push: # Update on merge on master if the changelog file has been updated
branches:
Expand All @@ -19,7 +19,7 @@ jobs:
PROJECT_ID: ${{ vars.DEV_MOBILITY_FEEDS_PROJECT_ID }}
DB_NAME: ${{ vars.DEV_POSTGRE_SQL_DB_NAME }}
REGION: ${{ vars.DEV_MOBILITY_FEEDS_REGION }}
RUN_POPULATE_SCRIPT: ${{ github.event.inputs.RUN_POPULATE_SCRIPT || false }}
RUN_POPULATE_SCRIPT: ${{ github.event.inputs.RUN_POPULATE_SCRIPT || 'true' }}
secrets:
DB_USER_PASSWORD: ${{ secrets.DEV_POSTGRE_USER_PASSWORD }}
DB_USER_NAME: ${{ secrets.DEV_POSTGRE_USER_NAME }}
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/db-update-prod.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Update the Mobility Database Schema
name: PROD Database Update
name: Database Update - PROD
on:
release: # Update on merge on master if the changelog file has been updated
paths:
Expand All @@ -17,7 +17,7 @@ jobs:
PROJECT_ID: ${{ vars.PROD_MOBILITY_FEEDS_PROJECT_ID }}
DB_NAME: ${{ vars.PROD_POSTGRE_SQL_DB_NAME }}
REGION: ${{ vars.PROD_MOBILITY_FEEDS_REGION }}
RUN_POPULATE_SCRIPT: ${{ github.event.inputs.RUN_POPULATE_SCRIPT || false }}
RUN_POPULATE_SCRIPT: ${{ github.event.inputs.RUN_POPULATE_SCRIPT || 'false' }}
secrets:
DB_USER_PASSWORD: ${{ secrets.PROD_POSTGRE_USER_PASSWORD }}
DB_USER_NAME: ${{ secrets.PROD_POSTGRE_USER_NAME }}
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/db-update-qa.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Update the Mobility Database Schema
name: QA Database Update
name: Database Update - QA
on:
push: # Update on merge on main branch if the changelog file has been updated
branches:
Expand All @@ -19,7 +19,7 @@ jobs:
PROJECT_ID: ${{ vars.QA_MOBILITY_FEEDS_PROJECT_ID }}
DB_NAME: ${{ vars.QA_POSTGRE_SQL_DB_NAME }}
REGION: ${{ vars.QA_MOBILITY_FEEDS_REGION }}
RUN_POPULATE_SCRIPT: ${{ github.event.inputs.RUN_POPULATE_SCRIPT || true }}
RUN_POPULATE_SCRIPT: ${{ github.event.inputs.RUN_POPULATE_SCRIPT || 'true' }}
secrets:
DB_USER_PASSWORD: ${{ secrets.QA_POSTGRE_USER_PASSWORD }}
DB_USER_NAME: ${{ secrets.QA_POSTGRE_USER_NAME }}
Expand Down
17 changes: 9 additions & 8 deletions .github/workflows/db-update.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,12 @@ on:
description: PostgreSQL Database Name
required: true
type: string
# TODO: remove this parameter once the populate script is no longer needed
RUN_POPULATE_SCRIPT:
description: Option to run the script that populates the database
required: false
default: false
type: boolean
default: 'false'
type: string
REGION:
description: GCP region
required: true
Expand Down Expand Up @@ -67,7 +68,7 @@ jobs:
url: 'jdbc:postgresql://${{ env.DB_IP }}:5432/${{ inputs.DB_NAME }}'

- name: Clear content of the database
if: inputs.RUN_POPULATE_SCRIPT
if: inputs.RUN_POPULATE_SCRIPT == 'true'
uses: liquibase-github-actions/[email protected]
with:
classpath: 'liquibase'
Expand All @@ -77,7 +78,7 @@ jobs:
url: 'jdbc:postgresql://${{ env.DB_IP }}:5432/${{ inputs.DB_NAME }}'

- name: Setup python
if: inputs.RUN_POPULATE_SCRIPT
if: inputs.RUN_POPULATE_SCRIPT == 'true'
uses: actions/setup-python@v4
with:
python-version: '3.9'
Expand All @@ -94,11 +95,11 @@ jobs:
cat config/.env.local
- name: Install requirements and generate db model
if: inputs.RUN_POPULATE_SCRIPT
if: inputs.RUN_POPULATE_SCRIPT == 'true'
run: scripts/db-gen.sh

- name: Download csv version of the database
if: inputs.RUN_POPULATE_SCRIPT
if: inputs.RUN_POPULATE_SCRIPT == 'true'
run: wget -O sources.csv https://bit.ly/catalogs-csv

- name: Validate file download
Expand All @@ -109,11 +110,11 @@ jobs:
run: echo "PATH=$(realpath sources.csv)" >> $GITHUB_OUTPUT

- name: Populate Database
if: inputs.RUN_POPULATE_SCRIPT
if: inputs.RUN_POPULATE_SCRIPT == 'true'
run: scripts/populate-db.sh ${{ steps.getpath.outputs.PATH }} > populate.log

- name: Upload log file for verification
if: inputs.RUN_POPULATE_SCRIPT
if: inputs.RUN_POPULATE_SCRIPT == 'true'
uses: actions/upload-artifact@v3
with:
name: populate.log
Expand Down

0 comments on commit bd7357b

Please sign in to comment.