-
Notifications
You must be signed in to change notification settings - Fork 0
61 lines (50 loc) · 1.96 KB
/
deploy-api.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
57
58
59
60
61
name: Deploy .NET API to Google Cloud Run
on:
push:
branches:
- main
workflow_dispatch: # Allows manual triggering
jobs:
build-and-deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Set up .NET
uses: actions/setup-dotnet@v2
with:
dotnet-version: "8.0.x"
- name: Authenticate to Google Cloud
uses: google-github-actions/auth@v2
with:
credentials_json: ${{ secrets.GCP_SA_KEY }}
- name: Set up Google Cloud SDK
uses: google-github-actions/setup-gcloud@v1
with:
project_id: ${{ secrets.GCP_PROJECT_ID }}
- name: Build the .NET project
run: |
dotnet publish ./API/TVR.Bundesliga.API -c Release -o ./out
- name: Configure Docker to use gcloud as a credential helper
run: |
gcloud auth configure-docker
- name: Build Docker image
run: |
docker build -t gcr.io/${{ secrets.GCP_PROJECT_ID }}/api:latest -f ./API/TVR.Bundesliga.API/Dockerfile ./API
- name: Push Docker image to Google Container Registry
run: |
docker push gcr.io/${{ secrets.GCP_PROJECT_ID }}/api:latest
- name: Deploy to Google Cloud Run
run: |
gcloud run deploy api \
--image gcr.io/${{ secrets.GCP_PROJECT_ID }}/api:latest \
--platform managed \
--region europe-west1 \
--allow-unauthenticated \
--set-env-vars ASPNETCORE_ENVIRONMENT=${{ secrets.ASPNETCORE_ENVIRONMENT }},\
MONGO_DB_CONNECTION_STRING="${{ secrets.MONGO_DB_CONNECTION_STRING }}",\
MONGO_DB_DATABASE_NAME="${{ secrets.MONGO_DB_DATABASE_NAME }}",\
GOOGLE_PROJECT_NAME=${{ secrets.GOOGLE_PROJECT_NAME }},\
QR_CODE_BUCKET=${{ secrets.QR_CODE_BUCKET }},\
QR_CODE_BUCKET_BASEURL=${{ secrets.QR_CODE_BUCKET_BASEURL }},\
STORAGE_ACCOUNT=${{ secrets.STORAGE_ACCOUNT }}