-
Notifications
You must be signed in to change notification settings - Fork 0
39 lines (36 loc) · 1.42 KB
/
build.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
name: Deploy API ML Brait
on:
push:
branches:
- 'main'
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- name: code checkout
uses: actions/checkout@v2
- name: install the gcloud cli
uses: google-github-actions/setup-gcloud@v0
with:
project_id: ${{ secrets.GOOGLE_PROJECT }}
service_account_key: ${{ secrets.GOOGLE_APPLICATION_CREDENTIALS }}
export_default_credentials: true
- name: build and push the docker image
env:
GOOGLE_PROJECT: ${{ secrets.GOOGLE_PROJECT }}
run: |
gcloud auth configure-docker asia-southeast2-docker.pkg.dev
docker build --platform linux/amd64 -t asia-southeast2-docker.pkg.dev/$GOOGLE_PROJECT/ci-cd-pipeline/brait-machine-learning-api:latest .
docker push asia-southeast2-docker.pkg.dev/$GOOGLE_PROJECT/ci-cd-pipeline/brait-machine-learning-api:latest
- name: deploy to Cloud Run
env:
GOOGLE_PROJECT: ${{ secrets.GOOGLE_PROJECT }}
FLASK_APP: ${{ secrets.FLASK_APP }}
run: |
gcloud run deploy brait-machine-learning-api \
--image asia-southeast2-docker.pkg.dev/$GOOGLE_PROJECT/ci-cd-pipeline/brait-machine-learning-api:latest \
--platform managed \
--region asia-southeast2 \
--allow-unauthenticated \
--set-env-vars=FLASK_APP=$FLASK_APP\
--max-instances=1