fix: switch to OIDC auth for Azure deploy, remove duplicate workflow
- Use azure/login@v2 with OIDC (Federated Identity) instead of publish-profile - Remove auto-generated main_soc-backend.yml (wrong paths) - Fix deployment package to include backend/ directory properly Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.6
parent
3759ecd1a6
commit
41727c52f4
@@ -25,11 +25,18 @@ jobs:
|
||||
run: |
|
||||
cd backend
|
||||
pip install -r requirements.txt --target=".python_packages/lib/site-packages"
|
||||
zip -r ../deploy.zip . -x "*.pyc" "__pycache__/*" ".venv/*" ".env"
|
||||
cd ..
|
||||
zip -r deploy.zip backend/ -x "backend/.venv/*" "backend/.env" "backend/__pycache__/*" "backend/*.pyc"
|
||||
|
||||
- name: Login to Azure
|
||||
uses: azure/login@v2
|
||||
with:
|
||||
client-id: ${{ secrets.AZUREAPPSERVICE_CLIENTID_E361D63054AD449285A5D65AA4425533 }}
|
||||
tenant-id: ${{ secrets.AZUREAPPSERVICE_TENANTID_62D66D4E65AC4A6C872064AD668AC691 }}
|
||||
subscription-id: ${{ secrets.AZUREAPPSERVICE_SUBSCRIPTIONID_5D7B0564A55F4209A91149F2642D3F69 }}
|
||||
|
||||
- name: Deploy to Azure Web App
|
||||
uses: azure/webapps-deploy@v2
|
||||
uses: azure/webapps-deploy@v3
|
||||
with:
|
||||
app-name: soc-backend
|
||||
publish-profile: ${{ secrets.AZURE_BACKEND_PUBLISH_PROFILE }}
|
||||
package: deploy.zip
|
||||
|
||||
@@ -1,76 +0,0 @@
|
||||
# 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: Build and deploy Python app to Azure Web App - soc-backend
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
contents: read #This is required for actions/checkout
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- name: Set up Python version
|
||||
uses: actions/setup-python@v5
|
||||
with:
|
||||
python-version: '3.12'
|
||||
|
||||
# 🛠️ Local Build Section (Optional)
|
||||
# The following section in your workflow is designed to catch build issues early on the client side, before deployment. This can be helpful for debugging and validation. However, if this step significantly increases deployment time and early detection is not critical for your workflow, you may remove this section to streamline the deployment process.
|
||||
- name: Create and Start virtual environment and Install dependencies
|
||||
run: |
|
||||
python -m venv antenv
|
||||
source antenv/bin/activate
|
||||
pip install -r requirements.txt
|
||||
|
||||
# By default, when you enable GitHub CI/CD integration through the Azure portal, the platform automatically sets the SCM_DO_BUILD_DURING_DEPLOYMENT application setting to true. This triggers the use of Oryx, a build engine that handles application compilation and dependency installation (e.g., pip install) directly on the platform during deployment. Hence, we exclude the antenv virtual environment directory from the deployment artifact to reduce the payload size.
|
||||
- name: Upload artifact for deployment jobs
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: python-app
|
||||
path: |
|
||||
.
|
||||
!antenv/
|
||||
|
||||
# 🚫 Opting Out of Oryx Build
|
||||
# If you prefer to disable the Oryx build process during deployment, follow these steps:
|
||||
# 1. Remove the SCM_DO_BUILD_DURING_DEPLOYMENT app setting from your Azure App Service Environment variables.
|
||||
# 2. Refer to sample workflows for alternative deployment strategies: https://github.com/Azure/actions-workflow-samples/tree/master/AppService
|
||||
|
||||
|
||||
deploy:
|
||||
runs-on: ubuntu-latest
|
||||
needs: build
|
||||
permissions:
|
||||
id-token: write #This is required for requesting the JWT
|
||||
contents: read #This is required for actions/checkout
|
||||
|
||||
steps:
|
||||
- name: Download artifact from build job
|
||||
uses: actions/download-artifact@v4
|
||||
with:
|
||||
name: python-app
|
||||
|
||||
- name: Login to Azure
|
||||
uses: azure/login@v2
|
||||
with:
|
||||
client-id: ${{ secrets.AZUREAPPSERVICE_CLIENTID_E361D63054AD449285A5D65AA4425533 }}
|
||||
tenant-id: ${{ secrets.AZUREAPPSERVICE_TENANTID_62D66D4E65AC4A6C872064AD668AC691 }}
|
||||
subscription-id: ${{ secrets.AZUREAPPSERVICE_SUBSCRIPTIONID_5D7B0564A55F4209A91149F2642D3F69 }}
|
||||
|
||||
- name: 'Deploy to Azure Web App'
|
||||
uses: azure/webapps-deploy@v3
|
||||
id: deploy-to-webapp
|
||||
with:
|
||||
app-name: 'soc-backend'
|
||||
slot-name: 'Production'
|
||||
|
||||
Reference in New Issue
Block a user