Hi, I’m wondering how one should deal with development and production environments when building and deploying applications with circleci.
The scenario is the folowing, I want to deploy a GCP Cloud run instance as such:
gcloud run deploy my-service --project $GCP_PROJECT
The workflow for production environment and development environment would be more or less the same, the only thing that would differ is the value of $GCP_PROJECT (and some other variables, but the use case is the same)
Is there a way where I can conditionally assign values in the same job in such cases? I want to avoid duplication inside the config so the config is more readable.
I’m aware about other features like branch filtering which enable me to differentiate between deploys to different environments, but I cannot find a way to avoid duplicating whole jobs just to assign different variables, like in the example below. Any suggestions on how to tackle deploying to different environments with as little duplication as possible?
The only way I see how I can achieve this right now is by using two virtually almost the same jobs and having multiple environment variables, as such:
jobs: prod-job: steps: - run: name: "My prod job" command: gcloud run deploy my-service --project $GCP_PROJECT dev-job: steps: - run: name: "My dev job" command: gcloud run deploy my-service --project $GCP_PROJECT_DEV
However my fear is that this will become a complete mess with how much stuff actually needs to be duplicated.