Skip to content

Commit 45c9363

Browse files
authored
revert: Install the right DB version when updating the DB content (#1431)
1 parent af6317c commit 45c9363

File tree

5 files changed

+13
-205
lines changed

5 files changed

+13
-205
lines changed

.github/actions/resolve-api-meta/action.yml

Lines changed: 0 additions & 80 deletions
This file was deleted.

.github/workflows/db-update-dev.yml

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -10,17 +10,6 @@ on:
1010
repository_dispatch: # Update on mobility-database-catalog repo dispatch
1111
types: [ catalog-sources-updated, gbfs-systems-updated ]
1212
workflow_dispatch:
13-
inputs:
14-
DRY_RUN:
15-
description: Dry run. Skip applying schema and content updates
16-
required: false
17-
default: false
18-
type: boolean
19-
INSTALL_LATEST:
20-
description: Install the latest (main) API version when true; when false install the currently deployed version.
21-
required: false
22-
default: false
23-
type: boolean
2413
jobs:
2514
update:
2615
uses: ./.github/workflows/db-update.yml
@@ -30,14 +19,6 @@ jobs:
3019
DB_NAME: ${{ vars.DEV_POSTGRE_SQL_DB_NAME }}
3120
ENVIRONMENT: ${{ vars.DEV_MOBILITY_FEEDS_ENVIRONMENT }}
3221
DB_ENVIRONMENT: ${{ vars.QA_MOBILITY_FEEDS_ENVIRONMENT }}
33-
API_BASE_URL: api-dev.mobilitydatabase.org
34-
# DRY_RUN is only if requested by the user in a workflow_dispatch
35-
DRY_RUN: ${{ github.event_name == 'workflow_dispatch' && inputs.DRY_RUN }}
36-
# We want to use the currently installed version (not the latest) if we received a dispatch from
37-
# mobility_database_catalog.
38-
# For a workflow_dispatch (manual trigger), we use the value set by the user.
39-
INSTALL_LATEST: ${{ (github.event_name == 'repository_dispatch' && false) || (github.event_name == 'workflow_dispatch' && inputs.INSTALL_LATEST) }}
40-
4122
secrets:
4223
DB_USER_PASSWORD: ${{ secrets.DEV_POSTGRE_USER_PASSWORD }}
4324
DB_USER_NAME: ${{ secrets.DEV_POSTGRE_USER_NAME }}
@@ -47,7 +28,6 @@ jobs:
4728
OP_SERVICE_ACCOUNT_TOKEN: ${{ secrets.OP_SERVICE_ACCOUNT_TOKEN }}
4829
OP_FEEDS_SERVICE_ACCOUNT_TOKEN: ${{ secrets.OP_FEEDS_SERVICE_ACCOUNT_TOKEN }}
4930
POSTGRE_SQL_INSTANCE_NAME: ${{ secrets.DB_INSTANCE_NAME }}
50-
API_TEST_REFRESH_TOKEN: ${{ secrets.DEV_API_TEST_REFRESH_TOKEN }}
5131
notify-slack-on-failure:
5232
needs: [ update ]
5333
if: always() && (needs.update.result == 'failure') && (github.event_name == 'repository_dispatch')

.github/workflows/db-update-prod.yml

Lines changed: 1 addition & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,10 @@
11
# Update the Mobility Database Schema
22
name: Database Update - PROD
33
on:
4-
workflow_dispatch: # Manual trigger
5-
inputs:
6-
DRY_RUN:
7-
description: Dry run. Skip applying schema and content updates
8-
required: false
9-
default: false
10-
type: boolean
11-
INSTALL_LATEST:
12-
description: Install the latest (main) API version when true; when false install the currently deployed version.
13-
required: false
14-
default: false
15-
type: boolean
4+
workflow_dispatch:
165
workflow_call:
176
repository_dispatch: # Update on mobility-database-catalog repo dispatch
187
types: [ catalog-sources-updated, gbfs-systems-updated ]
19-
208
jobs:
219
update:
2210
uses: ./.github/workflows/db-update.yml
@@ -26,16 +14,6 @@ jobs:
2614
DB_NAME: ${{ vars.PROD_POSTGRE_SQL_DB_NAME }}
2715
ENVIRONMENT: ${{ vars.PROD_MOBILITY_FEEDS_ENVIRONMENT }}
2816
DB_ENVIRONMENT: ${{ vars.PROD_MOBILITY_FEEDS_ENVIRONMENT }}
29-
API_BASE_URL: api.mobilitydatabase.org
30-
# DRY_RUN is only if requested by the user in a workflow_dispatch
31-
DRY_RUN: ${{ github.event_name == 'workflow_dispatch' && inputs.DRY_RUN }}
32-
# We want to use the currently installed version (not the latest) if we received a dispatch from
33-
# mobility_database_catalog.
34-
# We want to use the latest version if the trigger was workflow_call, because currently it's used for
35-
# upgrading (e.g. release.yml)
36-
# For a workflow_dispatch (manual trigger), we use the value set by the user.
37-
INSTALL_LATEST: ${{ (github.event_name == 'repository_dispatch' && false) || (github.event_name == 'workflow_call' && true) || (github.event_name == 'workflow_dispatch' && inputs.INSTALL_LATEST) }}
38-
3917
secrets:
4018
DB_USER_PASSWORD: ${{ secrets.PROD_POSTGRE_USER_PASSWORD }}
4119
DB_USER_NAME: ${{ secrets.PROD_POSTGRE_USER_NAME }}
@@ -45,7 +23,6 @@ jobs:
4523
OP_SERVICE_ACCOUNT_TOKEN: ${{ secrets.OP_SERVICE_ACCOUNT_TOKEN }}
4624
OP_FEEDS_SERVICE_ACCOUNT_TOKEN: ${{ secrets.OP_FEEDS_SERVICE_ACCOUNT_TOKEN }}
4725
POSTGRE_SQL_INSTANCE_NAME: ${{ secrets.DB_INSTANCE_NAME }}
48-
API_TEST_REFRESH_TOKEN: ${{ secrets.PROD_API_TEST_REFRESH_TOKEN }}
4926

5027
notify-slack-on-failure:
5128
needs: [ update ]

.github/workflows/db-update-qa.yml

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,6 @@
22
name: Database Update - QA
33
on:
44
workflow_dispatch:
5-
inputs:
6-
DRY_RUN:
7-
description: Dry run. Skip applying schema and content updates
8-
required: false
9-
default: false
10-
type: boolean
11-
INSTALL_LATEST:
12-
description: Install the latest (main) API version when true; when false install the currently deployed version.
13-
required: false
14-
default: false
15-
type: boolean
165
workflow_call:
176
repository_dispatch: # Update on mobility-database-catalog repo dispatch
187
types: [ catalog-sources-updated, gbfs-systems-updated ]
@@ -26,16 +15,6 @@ jobs:
2615
DB_NAME: ${{ vars.QA_POSTGRE_SQL_DB_NAME }}
2716
ENVIRONMENT: ${{ vars.QA_MOBILITY_FEEDS_ENVIRONMENT }}
2817
DB_ENVIRONMENT: ${{ vars.QA_MOBILITY_FEEDS_ENVIRONMENT }}
29-
API_BASE_URL: api-qa.mobilitydatabase.org
30-
# DRY_RUN is only if requested by the user in a workflow_dispatch
31-
DRY_RUN: ${{ github.event_name == 'workflow_dispatch' && inputs.DRY_RUN }}
32-
# We want to use the currently installed version (not the latest) if we received a dispatch from
33-
# mobility_database_catalog.
34-
# We want to use the latest version if the trigger was workflow_call, because currently it's used for
35-
# upgrading (e.g. release.yml)
36-
# For a workflow_dispatch (manual trigger), we use the value set by the user.
37-
INSTALL_LATEST: ${{ (github.event_name == 'repository_dispatch' && false) || (github.event_name == 'workflow_call' && true) || (github.event_name == 'workflow_dispatch' && inputs.INSTALL_LATEST) }}
38-
3918
secrets:
4019
DB_USER_PASSWORD: ${{ secrets.QA_POSTGRE_USER_PASSWORD }}
4120
DB_USER_NAME: ${{ secrets.QA_POSTGRE_USER_NAME }}
@@ -45,7 +24,6 @@ jobs:
4524
OP_SERVICE_ACCOUNT_TOKEN: ${{ secrets.OP_SERVICE_ACCOUNT_TOKEN }}
4625
OP_FEEDS_SERVICE_ACCOUNT_TOKEN: ${{ secrets.OP_FEEDS_SERVICE_ACCOUNT_TOKEN }}
4726
POSTGRE_SQL_INSTANCE_NAME: ${{ secrets.DB_INSTANCE_NAME }}
48-
API_TEST_REFRESH_TOKEN: ${{ secrets.QA_API_TEST_REFRESH_TOKEN }}
4927
notify-slack-on-failure:
5028
needs: [ update ]
5129
if: always() && (needs.update.result == 'failure') && (github.event_name == 'repository_dispatch')

.github/workflows/db-update.yml

Lines changed: 12 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,6 @@ on:
4646
POSTGRE_SQL_INSTANCE_NAME:
4747
description: PostgreSQL Instance Name
4848
required: true
49-
API_TEST_REFRESH_TOKEN:
50-
description: API refresh token used to resolve deployed API commit (used on repository_dispatch)
51-
required: false
5249
inputs:
5350
PROJECT_ID:
5451
description: GCP Project ID
@@ -70,61 +67,19 @@ on:
7067
description: GCP region
7168
required: true
7269
type: string
73-
API_BASE_URL:
74-
description: Base URL host for the API used to resolve version/commit (e.g. api-dev.mobilitydatabase.org)
75-
required: false
76-
default: api.mobilitydatabase.org
77-
type: string
78-
INSTALL_LATEST:
79-
description: Install the latest (main) API version when true; when false keep the currently deployed version.
80-
required: false
81-
default: false
82-
type: boolean
83-
DRY_RUN:
84-
description: Skip applying schema and content updates
85-
required: false
86-
default: false
87-
type: boolean
8870

8971
env:
9072
python_version: '3.11'
9173
liquibase_version: '4.33.0'
9274

9375
jobs:
94-
resolve-api-meta:
95-
name: 'Resolve API commit/version'
96-
runs-on: ubuntu-latest
97-
# Run this job for all triggers; the action itself will skip resolution when API_BASE_URL or token is not provided.
98-
# Keeping it unconditional ensures CHECKOUT_REF is always set (defaults to 'main') for downstream jobs.
99-
outputs:
100-
# Use resolved commit when available; otherwise default to 'main'.
101-
CHECKOUT_REF: ${{ steps.resolve.outputs.COMMIT_SHA != '' && steps.resolve.outputs.COMMIT_SHA || 'main' }}
102-
steps:
103-
- name: Checkout repo (for scripts and local action)
104-
uses: actions/checkout@v4
105-
- name: Resolve API commit/version
106-
id: resolve
107-
if: ${{ inputs.INSTALL_LATEST == false }}
108-
uses: ./.github/actions/resolve-api-meta
109-
with:
110-
api_base_url: ${{ inputs.API_BASE_URL }}
111-
api_refresh_token: ${{ secrets.API_TEST_REFRESH_TOKEN }}
112-
11376
db-schema-update:
11477
name: 'Database Schema Update'
11578
permissions: write-all
11679
runs-on: ubuntu-latest
117-
needs: [resolve-api-meta]
118-
# Run the schema update when the resolved checkout target is 'main' (install latest/main).
119-
# This covers both explicit INSTALL_LATEST runs and cases where resolution failed and CHECKOUT_REF fell back to 'main'.
120-
if: ${{ needs.resolve-api-meta.outputs.CHECKOUT_REF == 'main' }}
12180
steps:
122-
- name: Checkout repo
81+
- name: Checkout code
12382
uses: actions/checkout@v4
124-
with:
125-
# Use the job-level CHECKOUT_REF (already resolves to COMMIT_SHA or 'main')
126-
ref: ${{ needs.resolve-api-meta.outputs.CHECKOUT_REF }}
127-
fetch-depth: 0
12883

12984
- name: Authenticate to Google Cloud QA/PROD
13085
uses: google-github-actions/auth@v2
@@ -171,7 +126,6 @@ jobs:
171126
liquibase --version
172127
173128
- name: Run Liquibase
174-
if: ${{ !inputs.DRY_RUN }}
175129
working-directory: ${{ github.workspace }}/liquibase
176130
run: |
177131
export LIQUIBASE_COMMAND_CHANGELOG_FILE="changelog.xml"
@@ -185,15 +139,11 @@ jobs:
185139
name: 'Database Content Update'
186140
permissions: write-all
187141
runs-on: ubuntu-latest
188-
needs: [resolve-api-meta, db-schema-update]
189-
if: ${{ always() }}
142+
needs: db-schema-update
143+
if: ${{ github.event_name == 'repository_dispatch' || github.event_name == 'workflow_dispatch' }}
190144
steps:
191-
- name: Checkout repo
145+
- name: Checkout code
192146
uses: actions/checkout@v4
193-
with:
194-
# Use the job-level CHECKOUT_REF (already resolves to COMMIT_SHA or 'main')
195-
ref: ${{ needs.resolve-api-meta.outputs.CHECKOUT_REF }}
196-
fetch-depth: 0
197147

198148
- name: Setup python
199149
uses: actions/setup-python@v5
@@ -262,11 +212,11 @@ jobs:
262212
run: echo "PATH=$(realpath sources.csv)" >> $GITHUB_OUTPUT
263213

264214
- name: GTFS - Update Database Content
265-
if: ${{ !inputs.DRY_RUN && (env.UPDATE_TYPE == 'gtfs' || env.UPDATE_TYPE == 'manual') }}
215+
if: ${{ env.UPDATE_TYPE == 'gtfs' || env.UPDATE_TYPE == 'manual' }}
266216
run: scripts/populate-db.sh ${{ steps.getpath.outputs.PATH }} > populate.log
267217

268218
- name: GTFS - Upload log file for verification
269-
if: ${{ always() && !inputs.DRY_RUN && (env.UPDATE_TYPE == 'gtfs' || env.UPDATE_TYPE == 'manual') }}
219+
if: ${{ always() && (env.UPDATE_TYPE == 'gtfs' || env.UPDATE_TYPE == 'manual') }}
270220
uses: actions/upload-artifact@v4
271221
with:
272222
name: populate-${{ inputs.ENVIRONMENT }}.log
@@ -282,11 +232,11 @@ jobs:
282232
run: echo "PATH=$(realpath systems.csv)" >> $GITHUB_OUTPUT
283233

284234
- name: GBFS - Update Database Content
285-
if: ${{ !inputs.DRY_RUN && (env.UPDATE_TYPE == 'gbfs' || env.UPDATE_TYPE == 'manual') }}
235+
if: ${{ env.UPDATE_TYPE == 'gbfs' || env.UPDATE_TYPE == 'manual' }}
286236
run: scripts/populate-db.sh ${{ steps.getsyspath.outputs.PATH }} gbfs >> populate-gbfs.log
287237

288238
- name: GBFS - Upload log file for verification
289-
if: ${{ always() && !inputs.DRY_RUN && (env.UPDATE_TYPE == 'gbfs' || env.UPDATE_TYPE == 'manual') }}
239+
if: ${{ always() && (env.UPDATE_TYPE == 'gbfs' || env.UPDATE_TYPE == 'manual') }}
290240
uses: actions/upload-artifact@v4
291241
with:
292242
name: populate-gbfs-${{ inputs.ENVIRONMENT }}.log
@@ -295,7 +245,7 @@ jobs:
295245

296246
update-gcp-secret:
297247
name: Update GCP Secrets
298-
if: ${{ contains('repository_dispatch,workflow_dispatch', github.event_name) && !inputs.DRY_RUN }}
248+
if: ${{ github.event_name == 'repository_dispatch' || github.event_name == 'workflow_dispatch' }}
299249
runs-on: ubuntu-latest
300250
steps:
301251
- name: Authenticate to Google Cloud
@@ -333,3 +283,6 @@ jobs:
333283
echo "Secret $SECRET_NAME does not exist in project $PROJECT_ID, creating..."
334284
echo -n "$SECRET_VALUE" | gcloud secrets create $SECRET_NAME --data-file=- --replication-policy="automatic" --project=$PROJECT_ID
335285
fi
286+
287+
288+

0 commit comments

Comments
 (0)