-
Notifications
You must be signed in to change notification settings - Fork 0
52 lines (46 loc) · 1.51 KB
/
deploy_docker.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
name: Build and Deploy to Google Compute Engine
on:
push:
branches: [ main ]
paths:
- 'part2/05_Github-Action_CI-CD/**'
env:
PROJECT_ID: ${{ secrets.GCP_PROJECT_ID }}
DOCKER_IMAGE_NAME: streamlit
GCE_INSTANCE: ${{ secrets.GCE_INSTANCE }}
GCE_INSTANCE_ZONE: ${{ secrets.GCE_INSTANCE_ZONE }}
jobs:
setup-build-publish-deploy:
name: Setup, Build, Publish, and Deploy
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
# gcloud CLI 설정
- uses: google-github-actions/setup-gcloud@master
with:
version: '290.0.1'
service_account_key: ${{ secrets.SERVICE_ACCOUNT_KEY }}
project_id: ${{ secrets.GCP_PROJECT_ID }}
# gcloud에서 Docker 사용할 수 있도록 설정
- run: |-
gcloud --quiet auth configure-docker
# Model 파일 복사
- name: Copy model file
run: |
cd part2/05_Github-Action_CI-CD
sh copy_asset.sh
# Docker Image Build
- name: Build
run: |-
docker build part2/05_Github-Action_CI-CD --tag "gcr.io/$PROJECT_ID/$DOCKER_IMAGE_NAME:$GITHUB_SHA"
# Docker Image Push
- name: Publish
run: |-
docker push "gcr.io/$PROJECT_ID/$DOCKER_IMAGE_NAME:$GITHUB_SHA"
# Deploy : update-container로 업데이트 요청
- name: Deploy
run: |-
gcloud compute instances update-container "$GCE_INSTANCE" \
--zone "$GCE_INSTANCE_ZONE" \
--container-image "gcr.io/$PROJECT_ID/$DOCKER_IMAGE_NAME:$GITHUB_SHA"