updated azure yml config #13
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
name: Build and deploy Python app to Azure Web App - blinklog | |
on: | |
push: | |
branches: | |
- main | |
workflow_dispatch: | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Set up Python version | |
uses: actions/setup-python@v5 | |
with: | |
python-version: '3.12' | |
- name: Create and start virtual environment | |
run: | | |
python -m venv venv | |
source venv/bin/activate | |
- name: Install dependencies | |
run: | | |
source venv/bin/activate | |
pip install -r requirements.txt | |
- name: Zip artifact for deployment | |
run: zip -r release.zip . -x "*.git*" "venv/*" | |
- name: Upload artifact for deployment jobs | |
uses: actions/upload-artifact@v4 | |
with: | |
name: python-app | |
path: release.zip | |
deploy: | |
runs-on: ubuntu-latest | |
needs: build | |
environment: | |
name: 'Production' | |
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: python-app | |
- name: Unzip artifact for deployment | |
run: unzip release.zip -d deployment | |
- name: Login to Azure | |
uses: azure/login@v2 | |
with: | |
client-id: ${{ secrets.AZUREAPPSERVICE_CLIENTID_6829FC1876BE4260BF9FD5E534132CEA }} | |
tenant-id: ${{ secrets.AZUREAPPSERVICE_TENANTID_1060137AA8394E6EB3B545F8C2F86CAB }} | |
subscription-id: ${{ secrets.AZUREAPPSERVICE_SUBSCRIPTIONID_DA45F995372B4A4480863853C84F9C42 }} | |
- name: Collect static files | |
run: | | |
source venv/bin/activate | |
python manage.py collectstatic --noinput | |
- name: Run database migrations | |
run: | | |
source venv/bin/activate | |
python manage.py migrate | |
- name: Deploy to Azure Web App | |
uses: azure/webapps-deploy@v3 | |
id: deploy-to-webapp | |
with: | |
app-name: 'blinklog' | |
slot-name: 'Production' | |
package: 'deployment/release.zip' |