update config #11
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# .github/workflows/deploy.yml | |
name: Deploy FastAPI to Google Cloud Run | |
on: | |
push: | |
branches: | |
- main # Triggers the workflow on pushes to the 'main' branch | |
- dev | |
workflow_dispatch: # Allows manual triggering | |
env: | |
GCP_PROJECT_ID: whatsappllm | |
GCP_REGION: europe-west3 | |
jobs: | |
deploy: | |
runs-on: ubuntu-latest | |
steps: | |
# Step 1: Checkout the repository | |
- name: Checkout Repository | |
uses: actions/checkout@v4 | |
# Step 2: Authenticate to Google Cloud | |
- name: Authenticate to Google Cloud | |
uses: google-github-actions/auth@v1 | |
with: | |
credentials_json: ${{ secrets.GCP_SA_KEY }} | |
# Step 2.1: Verify Authentication [DEBUG] | |
- name: Verify Authentication | |
run: | | |
gcloud auth list | |
gcloud config list project | |
# Step 3: Configure Docker to use Google Cloud credentials | |
- name: Configure Docker for GCR | |
run: | | |
gcloud auth configure-docker gcr.io | |
# Step 3.1: Test Docker Authentication | |
- name: Test Docker Authentication | |
run: | | |
docker info | |
# Step 4: Build the Docker image | |
- name: Build Docker Image | |
run: | | |
IMAGE=gcr.io/$GCP_PROJECT_ID/whatsappllm:${{ github.sha }} | |
docker build -t $IMAGE . | |
# Step 5: Push the Docker image to GCR | |
- name: Push Docker Image to GCR | |
run: | | |
IMAGE=gcr.io/$GCP_PROJECT_ID/whatsappllm:${{ github.sha }} | |
docker push $IMAGE | |
# Ensure the image name matches the build step | |
# Step 6: Deploy to Google Cloud Run | |
- name: Deploy to Cloud Run | |
run: | | |
gcloud run deploy whatsappllm-service \ | |
--image gcr.io/$GCP_PROJECT_ID/whatsappllm:${{ github.sha }} \ | |
--region $GCP_REGION\ | |
--platform managed \ | |
--allow-unauthenticated | |
# Optional Step 7: Clean Up Docker Images (To save storage on the runner) | |
- name: Clean Up Docker Images | |
if: always() | |
run: | | |
docker image prune -f |