7575 required : false
7676 default : api.mobilitydatabase.org
7777 type : string
78- INSTALL_CURRENT :
79- description : Install the currently deployed API version when true; when false install main (latest) .
78+ INSTALL_LATEST :
79+ description : Install the latest (main) API version when true; when false keep the currently deployed version .
8080 required : false
8181 default : false
8282 type : boolean
@@ -97,64 +97,32 @@ jobs:
9797 # Run this job for all triggers; the action itself will skip resolution when API_BASE_URL or token is not provided.
9898 # Keeping it unconditional ensures CHECKOUT_REF is always set (defaults to 'main') for downstream jobs.
9999 outputs :
100- COMMIT_SHA : ${{ steps.resolve.outputs.COMMIT_SHA }}
101- API_VERSION : ${{ steps.resolve.outputs.API_VERSION }}
102- CHECKOUT_REF : ${{ steps.decide_ref.outputs.CHECKOUT_REF }}
100+ # Use resolved commit when available; otherwise default to 'main'.
101+ CHECKOUT_REF : ${{ steps.resolve.outputs.COMMIT_SHA != '' && steps.resolve.outputs.COMMIT_SHA || 'main' }}
103102 steps :
104103 - name : Checkout repo (for scripts and local action)
105104 uses : actions/checkout@v4
106105 - name : Resolve API commit/version
107106 id : resolve
108- # The composite action itself checks for a missing token and will skip resolution when none is provided.
107+ if : ${{ inputs.INSTALL_LATEST == false }}
109108 uses : ./.github/actions/resolve-api-meta
110109 with :
111110 api_base_url : ${{ inputs.API_BASE_URL }}
112111 api_refresh_token : ${{ secrets.API_TEST_REFRESH_TOKEN }}
113- - name : Determine install target ref
114- id : decide_ref
115- run : |
116- set -euo pipefail
117- EVENT='${{ github.event_name }}'
118- INSTALL_CURRENT='${{ inputs.INSTALL_CURRENT }}'
119- RESOLVED='${{ steps.resolve.outputs.RESOLVED }}'
120- COMMIT_SHA='${{ steps.resolve.outputs.COMMIT_SHA }}'
121- echo "event=$EVENT, install_current=$INSTALL_CURRENT, resolved=$RESOLVED, commit=$COMMIT_SHA"
122- if [ "$EVENT" = "repository_dispatch" ]; then
123- # For repository_dispatch we always install the currently deployed version; fail if missing
124- if [ "$RESOLVED" != "true" ] || [ -z "$COMMIT_SHA" ]; then
125- echo "ERROR: repository_dispatch requires a resolved API commit but none was found" >&2
126- exit 1
127- fi
128- echo "CHECKOUT_REF=$COMMIT_SHA" >> "$GITHUB_OUTPUT"
129- elif [ "$EVENT" = "workflow_dispatch" ]; then
130- # For manual runs, INSTALL_CURRENT=true -> install deployed; false -> install main
131- if [ "$INSTALL_CURRENT" = "true" ]; then
132- if [ "$RESOLVED" != "true" ] || [ -z "$COMMIT_SHA" ]; then
133- echo "ERROR: manual install requested current version but no resolved commit available" >&2
134- exit 1
135- fi
136- echo "CHECKOUT_REF=$COMMIT_SHA" >> "$GITHUB_OUTPUT"
137- else
138- echo "CHECKOUT_REF=main" >> "$GITHUB_OUTPUT"
139- fi
140- else
141- # push or other events: default to main
142- echo "CHECKOUT_REF=main" >> "$GITHUB_OUTPUT"
143- fi
144112
145113 db-schema-update :
146114 name : ' Database Schema Update'
147115 permissions : write-all
148116 runs-on : ubuntu-latest
149117 needs : [resolve-api-meta]
150- # If we need to install the currently installed version Only run schema update when we're NOT installing the currently deployed API version.
151- # INSTALL_CURRENT is a boolean input: true means install the deployed commit (skip schema),
152- # false means install the latest from main (apply schema updates).
153- if : ${{ !inputs.INSTALL_CURRENT }}
118+ # Only run the schema update when INSTALL_LATEST is true (we're installing main/latest).
119+ # If not, we have nothing to do since we will use the version already installed.
120+ if : ${{ inputs.INSTALL_LATEST == true }}
154121 steps :
155122 - name : Checkout repo (shallow)
156123 uses : actions/checkout@v4
157124 with :
125+ # Use the job-level CHECKOUT_REF (already resolves to COMMIT_SHA or 'main')
158126 ref : ${{ needs.resolve-api-meta.outputs.CHECKOUT_REF }}
159127 fetch-depth : 0
160128
@@ -218,11 +186,12 @@ jobs:
218186 permissions : write-all
219187 runs-on : ubuntu-latest
220188 needs : [resolve-api-meta, db-schema-update]
221- if : ${{ always() && contains('repository_dispatch,workflow_dispatch', github.event_name) }}
189+ if : ${{ always() }}
222190 steps :
223191 - name : Checkout repo (shallow)
224192 uses : actions/checkout@v4
225193 with :
194+ # Use the job-level CHECKOUT_REF (already resolves to COMMIT_SHA or 'main')
226195 ref : ${{ needs.resolve-api-meta.outputs.CHECKOUT_REF }}
227196 fetch-depth : 0
228197
@@ -240,8 +209,6 @@ jobs:
240209 uses : google-github-actions/setup-gcloud@v2
241210
242211 - name : Update .env file
243- env :
244- API_VERSION : ${{ needs.resolve-api-meta.outputs.API_VERSION }}
245212 run : |
246213 echo "PGUSER=${{ secrets.DB_USER_NAME }}" > config/.env.local
247214 echo "POSTGRES_USER=${{ secrets.DB_USER_NAME }}" >> config/.env.local
@@ -251,7 +218,6 @@ jobs:
251218 echo "POSTGRES_PORT=5432" >> config/.env.local
252219 echo "POSTGRES_HOST=localhost" >> config/.env.local
253220 echo "ENV=${{ inputs.ENVIRONMENT }}" >> config/.env.local
254- if [[ -n "${API_VERSION}" ]]; then echo "API_VERSION=${API_VERSION}" >> config/.env.local; fi
255221 cat config/.env.local
256222
257223 - name : Load secrets from 1Password
0 commit comments