-
Notifications
You must be signed in to change notification settings - Fork 0
44 lines (36 loc) · 1.18 KB
/
gcp.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
name: GCP
on:
push:
branches: [main]
jobs:
deploy:
name: Setup Gcloud Account
runs-on: ubuntu-latest
environment: gcp-prod
env:
IMAGE_NAME: gcr.io/${{ secrets.GCP_PROJECT_ID }}/site:latest
steps:
# git checkout
- name: Checkout
uses: actions/checkout@v2
# login to GCP
- name: Login to GCP
uses: google-github-actions/setup-gcloud@v0.2.0
with:
service_account_key: ${{ secrets.GCP_CREDENTIALS }}
project_id: ${{ secrets.GCP_PROJECT_ID }}
# gcloud configure docker
- name: Configure Docker
run: gcloud auth configure-docker --quiet
# build image
- name: Build Docker image
run: docker build -t $IMAGE_NAME .
# tag docker image with GCR URI
- name: Tag Docker image
run: docker tag $IMAGE_NAME $IMAGE_NAME
# push image to registry
- name: Push Docker image
run: docker push $IMAGE_NAME
# deploy image
- name: Deploy Docker image
run: gcloud run deploy site --image $IMAGE_NAME --region us-central1 --memory 1Gi --min-instances 0 --max-instances 1 --platform managed --port 8080 --allow-unauthenticated