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
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
8971env :
9072 python_version : ' 3.11'
9173 liquibase_version : ' 4.33.0'
9274
9375jobs :
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