How to deploy from Gitlab CI to AppEngine Standard environment?
AFAIK there are only 2 ways of deploying GAE apps:
- using the
gcloud app deploy
command:
gcloud app deploy - deploy the local code and/or configuration of your app to App Engine
- using the Admin API. From Deploying Your Apps with the Admin API:
To deploy a version of your app with the Admin API:
Both gcloud
(used in the 1st method) as well as gsutil
(used in the 1st step of the 2nd method) are part of the Google Cloud SDK, so you'll need to have the SDK installed on your runner.
Summarizing the required steps from a GAE deployment example using the 1st approach that I found in Getting started with Angular 6, GitLab CI/CD and Google App Engine (probably a good read for details):
- in gitlab set env vars with your GAE service account and project ID info
- in your
.gitlab-ci.yml
file's deployment section add abefore_script
section for installing the SDK (update for current SDK version)
before_script: - wget https://dl.google.com/dl/cloudsdk/channels/rapid/downloads/google-cloud-sdk-218.0.0-linux-x86.tar.gz - tar -xzf google-cloud-sdk-218.0.0-linux-x86.tar.gz - ./google-cloud-sdk/install.sh
and a script
section for the actual deployment, referencing those env vars:
script: - echo $GAE_KEY_FILE > gae_auth.json - ./google-cloud-sdk/bin/gcloud auth activate-service-account --key-file gae_auth.json - ./google-cloud-sdk/bin/gcloud app deploy --project=$GAE_PROJECT_ID