Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@ZeroCool2u
Last active August 26, 2019 20:35
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ZeroCool2u/c818f89906c9b46d28cb7de85a2860ce to your computer and use it in GitHub Desktop.
Save ZeroCool2u/c818f89906c9b46d28cb7de85a2860ce to your computer and use it in GitHub Desktop.
Setup Instructions and Example Github Action for Automated Deployment to Google Cloud Platform App Engine

An updated version of this example can be found here

There are a couple preliminary steps that you'll need to take prior to creating your deployment workflow.

  1. Create a service account and download the json private key file. Be sure you don't commit this file to your repo on accident! Best practice is to minimize the number of permissions this service account has, but for getting setup, you can give the service account project owner permissions and figure out exactly what scope is appropriate later. Click here for docs on creating a service account: https://cloud.google.com/iam/docs/creating-managing-service-account-keys#iam-service-account-keys-create-console
  2. Open a new terminal and cd into the folder your keyfile is located in, then run the following command:

base64 /path_to_your/key_files.json

  1. Copy and paste the resulting output into a new Secret, which you can create in your repos settings under Secrets. Name the secret GCLOUD_AUTH.
  2. Next, you'll need to enable the App Engine Admin API, so you can interact with it programatically. You may need to give it a few seconds before this is enabled successfully. https://cloud.google.com/appengine/docs/admin-api/accessing-the-api
  3. Finally, you should have this already if you're using App Engine, but make sure you have your App Engine app.yaml file prepared. I would also highly recommend creating a .gcloudignore and .gitignore file if you haven't already to ensure your service account key file isn't committed/pushed to Github or uploaded to App Engine.
  4. Copy the other file in this Gist, main.yml into your repository.

mkdir your/repo/.github/workflows touch your/repo/.github/main.yml

Open this newly created file and paste the contents of the example workflow. The only thing you need to do is to make sure your app.yaml file is named correctly.

name: AppEngine Deployment
# For this to work, you must verify the App Engine Admin API is enabled.
on: [push]
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- name: Retrieving the repo
uses: actions/checkout@v1
- name: Setting up GCloud Auth
uses: actions/gcloud/auth@master
env:
GCLOUD_AUTH: ${{ secrets.GCLOUD_AUTH }} # You must run base64 ./gcp_creds.json, then paste the output into the secrets area in your repo settings.
- name: Run deployment
uses: actions/gcloud/cli@master
env:
CLOUDSDK_CORE_PROJECT: facts-sender
with:
entrypoint: gcloud
args: app deploy ./front_end_app.yaml --quiet
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment