In this post I want to share a very simple Gitlab-CI pipeline that I use for building and deploying my toy slack bot. It has 4 stages and each stage 1 step (very simple).
- Deploy to Google Cloud (Run)
- Notify a private Slack channel
There is a case that this pipeline might change a bit in the future - since Gitlab is actually trying to simplify the integration between its shared runner / CI and clouds like google. Service Account definition or integration in the pipeline might become simpler and you might not be required to save JSON files in variables and then inject them on specific steps. For those interested on GitlabCI here is a list of issues that I am following their resolution
- A google cloud account and a project (usually you get one preconfigured)
- Inside the project you need to enable Google Container Registry and Google Cloud Run Apis
- I have created 2 separate Service Accounts, one with the appropriate rights on the project, that will allow my pipeline to push to my private container registry and the second one will allow the pipeline to make use of the gcloud cli and deploy/activate the new revisions of my Cloud Run application
- A Slack channel / Webhook, so that I send deployment status notifications - once my bot is deployed
- A bash script - on the root of the repo - more or less this one.