Skip to content

Commit

Permalink
Add ci.yml and cd.yml
Browse files Browse the repository at this point in the history
  • Loading branch information
aguscas committed Jun 27, 2024
1 parent cb0f4b3 commit 71587dd
Show file tree
Hide file tree
Showing 2 changed files with 75 additions and 0 deletions.
44 changes: 44 additions & 0 deletions .github/workflows/cd.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: Continuous Deployment

on:
push:
branches:
- main

jobs:
deploy:
runs-on: ubuntu-latest
permissions:
contents: read
id-token: write

steps:
- name: Checkout code
uses: actions/checkout@v2

- 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: 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 }}
31 changes: 31 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: Continuous Integration

on:
push:
branches: [ main ]
pull_request:
branches: [ main ]

jobs:
test:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: '3.9'

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt -r requirements-dev.txt -r requirements-test.txt
- name: Run model tests
run: make model-test

- name: Run API tests
run: make api-test

0 comments on commit 71587dd

Please sign in to comment.