CI/CD: Automate the deployment from Gitlab CI to Google App Engine.
Everyone wants magic to happen just like that đ but itâs not always as simple as expect of đ. Letâs see how the magic of automated deployment happens đ.
Coming straight to the point â this article talks about deploying a react-app from gitlab to google app engine.
Assuming you have a google cloud project and app engine setup already, and a gitlab CI is synced up with a gitlab runner. If not follow this link for google project
, this link for app app engine
, and this link for configuring gitlab runner
.
We would cover the following:
- Service account creation.
- Configure Gitlab CI/CD.
- Magic of Push!
SERVICE ACCOUNT CREATION
Go to IAM & admin.
Create a service account for gitlab deployment
with the following permission:
Create Key (JSON) upon completion of service account. This key would be needed in gitlab configuration.
CNFIGURE GITLAB CI/CD
Visit gitlab repo Settings â CI / CD â Variables â Expand:
PROJECT_ID: id of google cloud project
SERVICE_ACCOUNT: copy content of JSON key download for this service account and paste it here.
Additional variables can be added if sensitive info for example dbpassword, appKey, appSecrect etc needs to be passed in the build environment and eventually to the deployed app.
Following step is additional if you like to generate app.yaml
file from app.template.yaml
as app.yaml
doesnât support substituting variables from gitlab environment variables.
But be hold! Even though app.yaml
doesnât support it doesnât mean we canât do it đ! It can be achieved using this beautiful library called gae-ayaml-env. Add environment variables in gitlab CI like itâs done in previous step.
Make sure variables that need to be generated in app.yaml
file are prefixed with APP_
Create a app.template.yaml
file in the root directory of the project.
Create a .gitlab-ci.yaml
in the root of the project and add following content:
MAGIC OF PUSH! đ˛
Youâre literally one push away from the magic to happen!
git push origin develop
and thatâs it!