feat: Add CI/CD workflows for deploying GBFS Validator Java API#4
feat: Add CI/CD workflows for deploying GBFS Validator Java API#4
Conversation
…date project structure docs
|
|
| echo "🎉 Setup complete for project $PROJECT_ID" | ||
|
|
||
| # === Global LB IP addresses === | ||
| IPV4_NAME="${ENVIRONMENT}-lb-ipv4" |
There was a problem hiding this comment.
nitpick: I would add gbfs-validator-api-{environment} prefix instead of just environment, but I know that the IPs are already created, so we can discard this comment.
| echo " Re-run this script after the first successful deployment to apply this binding." | ||
| fi | ||
|
|
||
| # === Enable Artifact Registry API === |
There was a problem hiding this comment.
[out of scope]: In the case of an artifact registry, we should add rules to clean up "old" images.
| echo "✅ Downloaded ${ACTUAL_VERSION} (${FILE_SIZE} bytes)" | ||
| echo "resolved_version=${ACTUAL_VERSION}" >> "$GITHUB_OUTPUT" | ||
|
|
||
| - name: Create Artifact Registry repo if not exists |
There was a problem hiding this comment.
This can be done in TF. Having it in TF will allow us to have different "clean up" rules per environment. Example-missing rules, that we should add..
| @@ -0,0 +1,65 @@ | |||
| <?xml version="1.0" encoding="UTF-8"?> | |||
There was a problem hiding this comment.
[suggestion]: I would move this file out of the root folder, as it might give the wrong first impression to developers that this is a Java project.
| name: Deploy GBFS Validator - PROD | ||
|
|
||
| on: | ||
| workflow_dispatch: |
There was a problem hiding this comment.
Let's add the release trigger here to deploy the API using the git tag as the version.
There was a problem hiding this comment.
Just to be clear, it's a release on the infra code that will trigger, not a release on gbfs-validator-java.
That means there will be a version number for gbfs-validator-java and another one for the infra. It does not mean as much for infra, apart from debugging, but why not.
If you mean a release of gbfs-validator-java, we would probably need a repository_dispatch trigger, sent by gbfs-validator-java. I was hesitant to do that because it depends on a MobilityData secret and makes it less generic. But we could check for the existence of the secret before sending the trigger.
There was a problem hiding this comment.
This is a release on the gbfs-validator-java-infra, not the gbfs-validator-java. Tags don't need to match; in fact, they probably won't. We can update the service independently with no changes to the validator's code. What will be nice is to have some "notification" that we need to update the Java jar, as there is another gbfs-java-validator. This can be done by creating an issue.
Closes #2 and #3
Sets up the full CI/CD pipeline and GCP infrastructure bootstrapping for the GBFS Validator Java API across dev, qa, and prod environments.
What's included:
setup-environment.sh— bootstraps a GCP project: enables APIs, creates the deployer SA, sets IAM roles, creates the shared Artifact Registry repo, reserves LB IPs, and provisions a Google-managed SSL certsetup-deployer-sa-permissions.sh— grants Terraform-specific roles to the deployer SA.github/workflows/gbfs-validator-staging.yml— triggers: PR open/sync → dev, push to main → qa, manual dispatch → dev (default) or qa.github/workflows/gbfs-validator-prod.yml— manual dispatch only; deploys to prod.github/workflows/gbfs-validator-deployer.yml— reusable workflow: builds and pushes Docker image to Artifact Registry, then runs Terraforminfra/main.tf— passesproject_idexplicitly tocloud_runandload_balancermodules (critical for prod which uses a different GCP project)README.md— documents the environment structure, GCP setup steps, and deployment triggersNotes:
gbfs.api.mobilitydatabase.org; dev/qa use{env}.gbfs.api.mobilitydatabase.orggbfs-validator-prod; staging environments sharegbfs-validator-stagingTesting:
Since the workflows are not yet on
main, they cannot be triggered from the GitHub Actions web UI. Use theghCLI instead, targeting this branch (see below). You can set a release or snapshot version of gbfs-validator-java. See central.sonatype.com for the available releases. For snapshot unfortunately the snapshot repo cannot be browsed, but you can find some snapshots that were published hereOnce deployed, validate a GBFS feed against each environment:
All three should return a JSON validation report with HTTP 200. The json should also include the gbfs-validator-java version used.