Skip to content

Merge pull request #12 from QuizCast/dev #9

Merge pull request #12 from QuizCast/dev

Merge pull request #12 from QuizCast/dev #9

name: Build and Deploy to Azure
on:
push:
branches: [main]
workflow_dispatch:
env:
IMAGE_NAME: supabse-app
ACR_NAME: pawan
CONTAINER_APP_NAME: supabase-fastapi
RESOURCE_GROUP: github
jobs:
build-and-deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout Code
uses: actions/checkout@v4
- name: Log in to Azure
uses: azure/login@v2
with:
creds: ${{ secrets.AZURE_CREDENTIALS }}
- name: Log in to Azure Container Registry
run: |
az acr login --name ${{ env.ACR_NAME }}
- name: Create .env File with Secrets
run: |
echo "SUPABASE_URL=${{ secrets.SUPABASE_URL }}" >> .env
echo "SUPABASE_KEY=${{ secrets.SUPABASE_KEY }}" >> .env
echo "SUPABASE_BUCKET=${{ secrets.SUPABASE_BUCKET }}" >> .env
echo "SUPABASE_JWT_SECRET=${{ secrets.SUPABASE_JWT_SECRET }}" >> .env
echo ".env file created successfully."
- name: Build and Push Docker Image
run: |
IMAGE_TAG=${{ env.ACR_NAME }}.azurecr.io/${{ env.IMAGE_NAME }}:${{ github.sha }}
docker build -t $IMAGE_TAG .
docker push $IMAGE_TAG
- name: Deploy New Image to Azure Container App
run: |
IMAGE_TAG=${{ env.ACR_NAME }}.azurecr.io/${{ env.IMAGE_NAME }}:${{ github.sha }}
az containerapp update \
--name ${{ env.CONTAINER_APP_NAME }} \
--resource-group ${{ env.RESOURCE_GROUP }} \
--image $IMAGE_TAG