The previous zip command using shell glob (django/aiservice/*) was not reliably including all files, particularly start_gunicorn.sh, causing deployment failures with 'start_gunicorn.sh: not found'. Changed to cd into the directory and zip all contents (.) while excluding unnecessary files (.git, .venv, __pycache__, *.pyc). # Pull Request Checklist ## Description - [ ] **Description of PR**: Clear and concise description of what this PR accomplishes - [ ] **Breaking Changes**: Document any breaking changes (if applicable) - [ ] **Related Issues**: Link to any related issues or tickets ## Testing - [ ] **Test cases Attached**: All relevant test cases have been added/updated - [ ] **Manual Testing**: Manual testing completed for the changes ## Monitoring & Debugging - [ ] **Logging in place**: Appropriate logging has been added for debugging user issues - [ ] **Sentry will be able to catch errors**: Error handling ensures Sentry can capture and report errors - [ ] **Avoid Dev based/Prisma logging**: No development-only or Prisma-specific logging in production code ## Configuration - [ ] **Env variables newly added**: Any new environment variables are documented in .env.example file or mentioned in description --- ## Additional Notes <!-- Add any additional context, screenshots, or notes for reviewers here -->
116 lines
3.9 KiB
YAML
116 lines
3.9 KiB
YAML
# Docs for the Azure Web Apps Deploy action: https://github.com/Azure/webapps-deploy
|
|
# More GitHub Actions for Azure: https://github.com/Azure/actions
|
|
# More info on Python, GitHub Actions, and Azure App Service: https://aka.ms/python-webapps-actions
|
|
|
|
name: Deploy AI Service to Azure App Service - codeflash-aiservice-dev.azurewebsites.net
|
|
|
|
on:
|
|
push:
|
|
branches:
|
|
- main
|
|
paths:
|
|
- "django/aiservice/**"
|
|
- ".github/workflows/**"
|
|
workflow_dispatch:
|
|
|
|
jobs:
|
|
build:
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
|
|
# - name: Set up Python version
|
|
# uses: actions/setup-python@v1
|
|
# with:
|
|
# python-version: '3.11'
|
|
#
|
|
# - name: Create and start virtual environment
|
|
# run: |
|
|
# python -m venv venv
|
|
# source venv/bin/activate
|
|
|
|
# - name: Install dependencies
|
|
# run: |
|
|
# cd django/aiservice
|
|
# python -m pip install --upgrade pip
|
|
# pip install poetry
|
|
# poetry install
|
|
|
|
# - name: Publish to GitHub Packages
|
|
# run: |
|
|
# cd django/aiservice
|
|
# poetry config pypi-token.pypi ${{ secrets.GITHUB_TOKEN }}
|
|
# poetry publish --build
|
|
# env:
|
|
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
# Optional: Add step to run tests here (PyTest, Django test suites, etc.)
|
|
|
|
# - name: Run tests
|
|
# run: |
|
|
# cd django/aiservice
|
|
# poetry run pytest
|
|
- name: Install uv
|
|
uses: astral-sh/setup-uv@v7
|
|
|
|
- name: Generate requirements.txt
|
|
run: |
|
|
cd django/aiservice
|
|
uv pip compile pyproject.toml -o requirements.txt
|
|
# https://learn.microsoft.com/en-us/azure/app-service/configure-language-python
|
|
|
|
- name: Zip artifact for deployment
|
|
run: cd django/aiservice && zip -r ../../aiservice.zip . -x '*.git*' '.venv/*' '__pycache__/*' '*.pyc'
|
|
|
|
- name: Upload artifact for deployment jobs
|
|
uses: actions/upload-artifact@v4
|
|
with:
|
|
name: aiservice-artifact
|
|
path: |
|
|
aiservice.zip
|
|
!venv/
|
|
|
|
deploy:
|
|
runs-on: ubuntu-latest
|
|
needs: build
|
|
environment:
|
|
name: "dev"
|
|
url: ${{ steps.deploy-to-webapp.outputs.webapp-url }}
|
|
permissions:
|
|
id-token: write #This is required for requesting the JWT
|
|
|
|
steps:
|
|
- name: Download artifact from build job
|
|
uses: actions/download-artifact@v4
|
|
with:
|
|
name: aiservice-artifact
|
|
|
|
- name: Unzip artifact for deployment
|
|
run: unzip aiservice.zip
|
|
|
|
# - name: Install aiservice package from GitHub Packages
|
|
# run: |
|
|
# python -m pip install --index-url https://pypi.org/simple --extra-index-url https://npm.pkg.github.com/codeflash-ai aiservice
|
|
# env:
|
|
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
- name: Login to Azure
|
|
uses: azure/login@v1
|
|
with:
|
|
client-id: ${{ secrets.AZURE_CLIENT_ID }}
|
|
tenant-id: ${{ secrets.AZURE_TENANT_ID }}
|
|
subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
|
|
# with:
|
|
# client-id: ${{ secrets.AZUREAPPSERVICE_CLIENTID_897D7C1175A641AF841798FA6EB00A05 }}
|
|
# tenant-id: ${{ secrets.AZUREAPPSERVICE_TENANTID_4AC4B6C41D1C4C5EA848BB4C1E09AE16 }}
|
|
# subscription-id: ${{ secrets.AZUREAPPSERVICE_SUBSCRIPTIONID_7F61AF52B6434A77B01AEC73C1E034FC }}
|
|
|
|
- name: "Deploy to Azure App Service - codeflash-aiservice-dev.azurewebsites.net"
|
|
uses: azure/webapps-deploy@v2
|
|
id: deploy-to-webapp
|
|
with:
|
|
app-name: "codeflash-aiservice"
|
|
slot-name: "dev"
|
|
package: .
|
|
startup-command: "./start_gunicorn.sh"
|