Google App Engine으로 배포한 미니 프로젝트를 Github Actions를 사용해서 main 브랜치에 push 했을 때 배포되도록 적용해보고자 한다.
다음처럼 yml파일 이름 및 내용을 작성할 수 있는 창이 나온다.
오른쪽에는 Marketplace - Actions 에 App Engine 을 검색해서 원하는 설정을 넣어주면 된다.
내가 사용한 action - “Publish app to Google App Engine by zxyle”
name: deploy GAE
on:
# Triggers the workflow on push or pull request events but only for the master branch
push:
branches: [master]
pull_request:
branches: [master]
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
# This workflow contains a single job called "build"
build:
# The type of runner that the job will run on
runs-on: ubuntu-latest
# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v2
- name: Initialize Google Cloud SDK
uses: zxyle/publish-gae-action@master
with:
service_account_email: ${{ secrets.GCP_SA_EMAIL }}
service_account_key: ${{ secrets.GCP_SA_KEY }}
project_id: ${{ secrets.PROJECT_ID }}
# An optional variables parameter can be used
gae_variables: ${{ secrets.GAE_VARIABLES }}
- name: Publish app to Google App Engine
run: |
# This client-secret.json is converted by GCP_SA_KEY.
gcloud auth activate-service-account ${{ secrets.GCP_SA_EMAIL }} --key-file=client-secret.json
gcloud config set project ${{ secrets.PROJECT_ID }}
gcloud -q app deploy app.yaml --promote
# Suppose you need a cron task.
# gcloud -q app deploy cron.yaml
secret key
설정이 필요하기 때문에 필요한 키들을 만들어 주고 Github Repository Secret Key 에 추가하자~GCP_SA_EMAIL
- 새로 만든 계정에서 GCP에서 제공해주는 이메일 GCP_SA_KEY
- 새로 만든 계정 키PROJECT_ID
- 기존 프로젝트 IDGCP - IAM 및 관리자 - 사용자 계정
에 들어가서 새로운 계정을 만들어 준다.
이름, 권한, 키를 설정 해줘야 한다.
이 권한은 IAM
에서 수정이 가능하다.
App Engine 기준 설정해줘야 하는 권한들이다.
끝이당
이제 main이나 master 브랜치에 push 만 하면 배포를 할 수 있게 되었다!
배포 과정과 결과는 Actions 탭에서 확인할 수 있땅 이예~!