-
Notifications
You must be signed in to change notification settings - Fork 0
56 lines (47 loc) · 1.77 KB
/
deploy_cloudrun_machine_learning.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
53
54
55
56
name: Deployment of machine learning system to CloudRun
on:
push:
branches:
- develop
- feature/machine-learning/cicd
permissions:
contents: read
pages: write
id-token: write
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup gcloud CLI
uses: google-github-actions/setup-gcloud@v2
with:
project_id: ${{ secrets.GCP_PROJECT_ID }}
skip_install: false
version: latest
# gcloud CLIを認証するステップを追加
- name: Auth
uses: google-github-actions/auth@v0.4.0
with:
workload_identity_provider: ${{ secrets.WORKLOAD_IDENTITY_PROVIDER }}
service_account: ${{ secrets.SERVICE_ACCOUNT }}
- name: Build Docker image
run: |
docker build \
--build-arg GCP_PROJECT_ID=${{ secrets.GCP_PROJECT_ID }} \
--build-arg BUCKET_NAME_FOR_ML=${{ secrets.BUCKET_NAME_FOR_ML }} \
--tag=gcr.io/${{ secrets.GCP_PROJECT_NAME_FOR_ML }}/${{ secrets.GCP_IMAGE_NAME_FOR_ML }}:latest \
--file=./machine_learning/Dockerfile \
--platform linux/amd64 ./machine_learning
- name: Authenticate Docker to GCP
run: gcloud auth configure-docker --quiet
- name: Push Docker image to Artifact Registry
run: |
docker push gcr.io/${{ secrets.GCP_PROJECT_NAME_FOR_ML }}/${{ secrets.GCP_IMAGE_NAME_FOR_ML }}:latest
- name: Deploy to Cloud Run
run: |
gcloud run deploy ${{ secrets.GCP_IMAGE_NAME_FOR_ML }} \
--image gcr.io/${{ secrets.GCP_PROJECT_NAME_FOR_ML }}/${{ secrets.GCP_IMAGE_NAME_FOR_ML }}:latest \
--region ${{ secrets.REGION }} \
--platform managed