To deploy to Google App Engine, you will need to create a container that can authenticate with your Google Account, and with the appropriate Google product, as well as run the Google Cloud CLI to execute your intended commands.
We maintain an example repository with an image stored on Docker Hub to simplify this process. You can copy setup instructions from this repo or reuse the Dockerfile, our turnkey Google Cloud image or our GCR authentication generator simply by adding the necessary elements from our Google Cloud repo to your codeship-services.yml file.
To deploy to App Engine, you will need to define a Google Service
account as well as add your Google credentials to your
encrypted environment variables so that the
gcloud utility can authenticate
For full instructions, see the authentication portion of our Google Cloud documentation.
Some Google Cloud services will require that you add your CodeShip public key for authentication purposes.
Note that Google may fail authentication if you do not add the Google
Cloud user the key is for to the end of the key. For example, if the
Google Cloud user is
deploy@CodeShip, you will want to add
deploy@CodeShip to the end of the SSH key itself, otherwise Google
will not load the key for the user appropriately.
Note that this example adds your Google Cloud account credentials as
encrypted environment variables and mounts the repository as a
/deploy folder inside the container so that it is usable as
part of the build.
After defining your authentication variables and your deployment service, you will want to run deployment commands via your codeship-steps.yml file.
Because each step runs in a separate group of containers, you will likely want to bundle you Google Cloud commands together in a script file that you add to your repository and call from a step:
- name: google-cloud-deployment
Inside this deployment script will be all commands you want to run via the Google Cloud or Kubernetes CLI, both included in the [deployment image that we maintain]((https://hub.docker.com/r/codeship/google-cloud-deployment/).
Here is an example deployment script that you can use as a basis for your own deployments. Note that it authenticates at the top using the command discussed earlier.
# Authenticate with the Google Services
# switch to the directory containing your app.yml (or similar) configuration file
# note that your repository is mounted as a volume to the /deploy directory
# deploy the application
gcloud app deploy --quiet
Please see the documentation for
gcloud app deploy on which more options are available and how they affect the deployment.