|
11 | 11 |
|
12 | 12 | env: |
13 | 13 | GOOGLE_APPLICATION_CREDENTIALS: ${{ secrets.GCP_SA_KEY }} |
14 | | - IMAGE_NAME: europe-west3-docker.pkg.dev/thf-climate-cloud/thf-climate/thf-climate |
| 14 | + BACKEND_IMAGE_NAME: europe-west3-docker.pkg.dev/thf-climate-cloud/thf-climate/thf-climate |
| 15 | + FRONTEND_IMAGE_NAME: europe-west3-docker.pkg.dev/thf-climate-cloud/thf-climate-frontend/thf-climate-frontend |
15 | 16 |
|
16 | 17 | steps: |
17 | 18 | # Step 1: Checkout the code |
@@ -42,27 +43,44 @@ jobs: |
42 | 43 | run: | |
43 | 44 | gcloud auth configure-docker europe-west3-docker.pkg.dev |
44 | 45 |
|
45 | | - # Step 6: Docker Login using Access Token |
46 | | - - name: Build Docker image |
| 46 | + # Step 6: Build and Deploy the backend |
| 47 | + - name: Build Docker image (backend) |
47 | 48 | working-directory: ./backend |
48 | 49 | run: | |
49 | | - docker buildx build --platform linux/amd64 -t $IMAGE_NAME:latest . |
50 | | -
|
51 | | - # Step 7: Build Docker image |
52 | | - - name: Push Docker image to Artifact Registry |
| 50 | + docker buildx build --platform linux/amd64 -t $BACKEND_IMAGE_NAME:latest . |
| 51 | + - name: Push Docker image to Artifact Registry (backend) |
53 | 52 | working-directory: ./backend |
54 | 53 | run: | |
55 | | - docker push $IMAGE_NAME:latest |
56 | | -
|
57 | | - # Step 8: Push Docker image to Google Artifact Registry |
58 | | - - name: Deploy to Cloud Run |
| 54 | + docker push $BACKEND_IMAGE_NAME:latest |
| 55 | + - name: Deploy to Cloud Run (backend) |
59 | 56 | working-directory: ./backend |
60 | 57 | run: | |
61 | 58 | gcloud run deploy thf-climate-run \ |
62 | | - --image=$IMAGE_NAME:latest \ |
| 59 | + --image=$BACKEND_IMAGE_NAME:latest \ |
63 | 60 | --port=8000 \ |
64 | 61 | --region=europe-west3 \ |
65 | 62 | --allow-unauthenticated \ |
66 | 63 | --platform=managed \ |
67 | 64 | --min-instances=1 \ |
68 | 65 | --max-instances=5 |
| 66 | +
|
| 67 | + # Step 7: Build and Deploy the frontend |
| 68 | + - name: Build Docker image (frontend) |
| 69 | + working-directory: ./frontend |
| 70 | + run: | |
| 71 | + docker buildx build --platform linux/amd64 -t $FRONTEND_IMAGE_NAME:latest . |
| 72 | + - name: Push Docker image to Artifact Registry (frontend) |
| 73 | + working-directory: ./frontend |
| 74 | + run: | |
| 75 | + docker push $FRONTEND_IMAGE_NAME:latest |
| 76 | + - name: Deploy to Cloud Run (frontend) |
| 77 | + working-directory: ./frontend |
| 78 | + run: | |
| 79 | + gcloud run deploy thf-climate-frontend-run \ |
| 80 | + --image=$FRONTEND_IMAGE_NAME:latest \ |
| 81 | + --port=80 \ |
| 82 | + --region=europe-west3 \ |
| 83 | + --allow-unauthenticated \ |
| 84 | + --platform=managed \ |
| 85 | + --min-instances=1 \ |
| 86 | + --max-instances=5 |
0 commit comments