-
Notifications
You must be signed in to change notification settings - Fork 0
55 lines (44 loc) · 1.66 KB
/
cd.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
name: Continuous Deployment
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
jobs:
deploy:
runs-on: ubuntu-latest
permissions:
contents: read
id-token: write
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Install dependencies
run: |
pip install -r requirements.txt -r requirements-dev.txt -r requirements-test.txt
- name: Train Model
run: python3 ./challenge/train.py
- name: Set up Cloud SDK
uses: google-github-actions/[email protected]
with:
project_id: ${{ secrets.GCP_PROJECT_ID }}
service_account_key: ${{ secrets.GCP_SA_KEY }}
export_default_credentials: true
- name: Configure Docker to use the gcloud command-line tool as a credential helper
run: gcloud auth configure-docker
- name: Build and Push Docker image
run: |
docker build -t gcr.io/${{ secrets.GCP_PROJECT_ID }}/flight-predictor . --platform linux/amd64
docker push gcr.io/${{ secrets.GCP_PROJECT_ID }}/flight-predictor
- name: Deploy to Cloud Run
id: deploy
run: |
echo "Deploying to Google Cloud Run..."
URL=$(gcloud run deploy flight-predictor-api --image gcr.io/${{ secrets.GCP_PROJECT_ID }}/flight-predictor --platform managed --region us-central1 --allow-unauthenticated --format="value(status.url)")
echo "::set-output name=url::$URL"
echo "Deployment completed at $URL"
- name: Set STRESS_URL for Makefile
run: echo "STRESS_URL=${{ steps.deploy.outputs.url }}" >> $GITHUB_ENV
- name: Run stress tests
run: |
make stress-test STRESS_URL=${{ env.STRESS_URL }}