Skip to content

Instantly share code, notes, and snippets.

@qlawmarq
Last active December 18, 2023 02:41
Show Gist options
  • Save qlawmarq/6f2b2eba8b081b97fc34eb39df6b6811 to your computer and use it in GitHub Desktop.
Save qlawmarq/6f2b2eba8b081b97fc34eb39df6b6811 to your computer and use it in GitHub Desktop.
GitHub Actions: Deployer for Node.js app to Google App Engine
name: Deployer
#####
#
# Add this file to .github/workflows/google_app_engine_deployer.yml, then GitHub Actions will detect any updates on master/main branch and deploy changes.
# This example uses Node.js 18. You can choose any language you like.
# The build command is also `npm run build', change it as you like.
#
# 1. Set up service account for deployment and create key.json and set it to env variable
# 2. Create your app.yaml if you never deploy the app to GAE
# 3. Add this file to your app repo and push, then see if the GitHub action works fine.
#
#####
on:
push:
branches: [ master, main ]
jobs:
run-deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Setup Node
uses: actions/setup-node@v1
with:
node-version: 18.x
- name: Package Install
run: npm install
- name: Build
run: npm run build
- name: Cloud Auth
uses: google-github-actions/auth@v0
with:
# You need to add GCP_CREDENTIALS to your GitHub secrets:
# cat your-service-key.json | base64 | pbcopy
credentials_json: '${{ secrets.GCP_CREDENTIALS }}'
- name: Set up Cloud SDK
uses: google-github-actions/setup-gcloud@v0
- name: Deploy App to App Engine
run: gcloud app deploy --quiet
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment