This repository was archived by the owner on Jun 3, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
128 lines (108 loc) 路 3.74 KB
/
Copy pathdeploy.yml
File metadata and controls
128 lines (108 loc) 路 3.74 KB
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
name: Deploy on Google Run
on:
pull_request:
branches:
- develop
- main
push:
branches:
- develop
- main
jobs:
lint:
uses: ./.github/workflows/ruff.yml
deploy-backend:
runs-on: ubuntu-latest
needs: lint
outputs:
BACKEND_URL: ${{ steps.deploy-backend.outputs.BACKEND_URL }}
env:
PROJECT_ID: deepskin-451908
REGION: europe-west1
GC_CREDENTIALS: ${{ secrets.GC_CLEM }}
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Set up Cloud SDK
uses: google-github-actions/auth@v1
with:
credentials_json: ${{ secrets.GC_CLEM }}
- name: Create credentials file
run: |
echo "$GC_CREDENTIALS" > credentials.json
- name: Prepare credentials
uses: actions/upload-artifact@v4
with:
name: credentials
path: |
credentials.json
format.py
- name: Configure gcloud
run: |
gcloud config set project $PROJECT_ID
gcloud config set run/region $REGION
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Build and push Docker image backend
run: |
docker build \
-f deployment/Dockerfile \
--platform linux/amd64 \
--build-arg GOOGLE_CREDENTIALS="$(echo "${{ secrets.GC_CLEM }}" | base64)" \
-t deepskin-backend \
.
docker tag deepskin-backend europe-west1-docker.pkg.dev/deepskin-451908/deepskin/deepskin-backend
gcloud auth configure-docker europe-west1-docker.pkg.dev
docker push europe-west1-docker.pkg.dev/deepskin-451908/deepskin/deepskin-backend
- name: Deploy backend to Cloud Run
run: |
gcloud run deploy deepskin-back \
--image europe-west1-docker.pkg.dev/$PROJECT_ID/deepskin/deepskin-backend \
--platform managed \
--region $REGION \
--allow-unauthenticated \
--timeout 900s \
--port 5100 \
--memory 2Gi \
--format json > backend_output.json
- name: Set Backend URL as output
id: deploy-backend
run: |
BACKEND_URL=$(python -c "import json; print(json.load(open('backend_output.json'))['status']['url'])")
echo "BACKEND_URL=$BACKEND_URL" >> $GITHUB_OUTPUT
echo "Backend URL: $BACKEND_URL"
deploy-frontend:
runs-on: ubuntu-latest
needs: deploy-backend
env:
PROJECT_ID: deepskin-451908
REGION: europe-west1
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Set up Cloud SDK
uses: google-github-actions/auth@v1
with:
credentials_json: ${{ secrets.GC_CLEM }}
- name: Build and push frontend image
run: |
docker build -f streamlit/Dockerfile --platform linux/amd64 -t deepskin-frontend .
docker tag deepskin-frontend europe-west1-docker.pkg.dev/deepskin-451908/deepskin/deepskin-frontend
gcloud auth configure-docker europe-west1-docker.pkg.dev
docker push europe-west1-docker.pkg.dev/deepskin-451908/deepskin/deepskin-frontend
- name: Deploy to Cloud Run
run: |
gcloud run deploy deepskin-front \
--image europe-west1-docker.pkg.dev/$PROJECT_ID/deepskin/deepskin-frontend \
--platform managed \
--region $REGION \
--allow-unauthenticated \
--set-env-vars BACKEND_URL=${{ needs.deploy-backend.outputs.BACKEND_URL }} \
--port 8501
pytest:
needs:
- deploy-frontend
- deploy-backend
uses: ./.github/workflows/pytest.yml
with:
BACKEND_URL: ${{ needs.deploy-backend.outputs.BACKEND_URL }}