@@ -10,14 +10,16 @@ jobs:
1010 runs-on : ubuntu-latest
1111
1212 env :
13+ GOOGLE_PROJECT_ID : ${{ vars.GOOGLE_PROJECT_ID }}
14+ GOOGLE_EARTH_ENGINE_SERVICE_ACCOUNT_CREDENTIALS : ${{ secrets.GOOGLE_EARTH_ENGINE_SERVICE_ACCOUNT_CREDENTIALS }}
15+ GOOGLE_EARTH_ENGINE_SERVICE_ACCOUNT_EMAIL : ${{ secrets.GOOGLE_EARTH_ENGINE_SERVICE_ACCOUNT_EMAIL }}
16+ ENVIRONMENT : ${{ vars.ENVIRONMENT }}
1317 GOOGLE_APPLICATION_CREDENTIALS : ${{ secrets.GCP_SA_KEY }}
1418 BACKEND_IMAGE_NAME : europe-west3-docker.pkg.dev/thf-climate-cloud/thf-climate/thf-climate
1519 FRONTEND_IMAGE_NAME : europe-west3-docker.pkg.dev/thf-climate-cloud/thf-climate-frontend/thf-climate-frontend
1620
1721 steps :
18- # Step 1: Checkout the code
19- - name : Checkout code
20- uses : actions/checkout@v2
22+ - uses : actions/checkout@v3
2123
2224 # Step 2: Decode and Write the Service Account Key to a file properly
2325 - name : Set up Google Cloud credentials
@@ -43,11 +45,28 @@ jobs:
4345 run : |
4446 gcloud auth configure-docker europe-west3-docker.pkg.dev
4547
46- # Step 6: Build and Deploy the backend
47- - name : Build Docker image (backend)
48+ # Step 6: Build and the run the backend
49+ - name : Build and Run the Docker image (backend)
4850 working-directory : ./backend
4951 run : |
5052 docker buildx build --platform linux/amd64 -t $BACKEND_IMAGE_NAME:latest .
53+ docker run -d -p 8000:8000 --name thf-climate-backend $BACKEND_IMAGE_NAME
54+ - name : Wait for the application to start
55+ working-directory : ./backend
56+ run : |
57+ timeout 30 bash -c 'until curl -s http://127.0.0.1:8000/; do sleep 1; done'
58+
59+ # Step 7: Run the tests against the local application
60+ - name : Install dependencies and Run tests (backend)
61+ working-directory : ./backend
62+ env :
63+ API_BASE_URL : " http://127.0.0.1:8000"
64+ run : |
65+ python -m pip install --upgrade pip
66+ pip install -r requirements-dev.txt
67+ pytest
68+
69+ # Step 8: Push and Deploy the backend on Google cloud
5170 - name : Push Docker image to Artifact Registry (backend)
5271 working-directory : ./backend
5372 run : |
6483 --min-instances=1 \
6584 --max-instances=5
6685
67- # Step 7 : Build and Deploy the frontend
86+ # Step 9 : Build and Deploy the frontend
6887 - name : Build Docker image (frontend)
6988 working-directory : ./frontend
7089 run : |
0 commit comments