Skip to content

Change setup-glcloud version #17

Change setup-glcloud version

Change setup-glcloud version #17

Workflow file for this run

name: Continuous Deployment
on:
push:
branches:
- main
- develop
- release/*
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: |
export PYTHONPATH=$PYTHONPATH:$(pwd)
python3 ./challenge/train.py
- name: Set up Cloud SDK
uses: google-github-actions/setup-gcloud@v2.1.0
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 (Main)
id: deploy-main
if: github.ref == 'refs/heads/main'
run: |
echo "Deploying Main API to Google Cloud Run..."
URL=$(gcloud run deploy main-api --image gcr.io/${{ secrets.GCP_PROJECT_ID }}/flight-predictor --platform managed --region us-central1 --format="value(status.url) --allow-unauthenticated")
echo "::set-output name=url::$URL"
echo "Deployment completed at $URL"
- name: Deploy to Cloud Run (Develop)
id: deploy-develop
if: github.ref == 'refs/heads/develop'
run: |
echo "Deploying Develop API to Google Cloud Run..."
URL=$(gcloud run deploy develop-api --image gcr.io/${{ secrets.GCP_PROJECT_ID }}/flight-predictor --platform managed --region us-central1 --format="value(status.url) --allow-unauthenticated")
echo "::set-output name=url::$URL"
echo "Deployment completed at $URL"
- name: Deploy to Cloud Run (Release)
id: deploy-release
if: contains(github.ref, 'refs/heads/release/')
run: |
echo "Deploying Release API to Google Cloud Run..."
URL=$(gcloud run deploy release-api --image gcr.io/${{ secrets.GCP_PROJECT_ID }}/flight-predictor --platform managed --region us-central1 --format="value(status.url) --allow-unauthenticated")
echo "::set-output name=url::$URL"
echo "Deployment completed at $URL"
- name: Set STRESS_URL for Makefile
run: |
if [ "${{ github.ref }}" == "refs/heads/main" ]; then
echo "STRESS_URL=${{ steps.deploy-main.outputs.url }}" >> $GITHUB_ENV
elif [ "${{ github.ref }}" == "refs/heads/develop" ]; then
echo "STRESS_URL=${{ steps.deploy-develop.outputs.url }}" >> $GITHUB_ENV
elif [[ "${{ github.ref }}" == refs/heads/release/* ]]; then
echo "STRESS_URL=${{ steps.deploy-release.outputs.url }}" >> $GITHUB_ENV
fi
- name: Run stress tests
run: |
make stress-test STRESS_URL=${{ env.STRESS_URL }}