Merge pull request #11 from aabboudi/dev #10
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
# 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 Django app to Azure Web App - yesalumni-morocco | |
on: | |
push: | |
branches: | |
- main | |
pull_request: | |
branches: | |
- main | |
workflow_dispatch: | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
env: | |
SECRET_KEY: ${{ secrets.SECRET_KEY }} | |
AZURE_ACCOUNT_NAME: ${{ secrets.AZURE_ACCOUNT_NAME }} | |
AZURE_ACCOUNT_KEY: ${{ secrets.AZURE_ACCOUNT_KEY }} | |
AZURE_CONTAINER: ${{ secrets.AZURE_CONTAINER }} | |
EMAIL_HOST_USER: ${{ secrets.EMAIL_HOST_USER }} | |
EMAIL_HOST_PASSWORD: ${{ secrets.EMAIL_HOST_PASSWORD }} | |
DEFAULT_FROM_EMAIL: ${{ secrets.DEFAULT_FROM_EMAIL }} | |
DATABASE_NAME: ${{ secrets.DATABASE_NAME }} | |
DATABASE_USER: ${{ secrets.DATABASE_USER }} | |
DATABASE_PASSWORD: ${{ secrets.DATABASE_PASSWORD }} | |
DATABASE_HOST: ${{ secrets.DATABASE_HOST }} | |
steps: | |
- 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 Python dependencies | |
run: pip install -r requirements.txt | |
- name: Make and apply migrations | |
run: | | |
python manage.py makemigrations | |
python manage.py migrate | |
- name: Install UI dependencies and build CSS | |
run: | | |
cd ./ui | |
npm install | |
npm run build:css | |
cd .. | |
- name: Collect static files | |
run: python manage.py collectstatic --noinput | |
- name: Zip artifact for deployment | |
run: zip release.zip ./* -r | |
- name: Upload artifact for deployment jobs | |
uses: actions/upload-artifact@v4 | |
with: | |
name: django-app | |
path: | | |
release.zip | |
!venv/ | |
deploy: | |
runs-on: ubuntu-latest | |
needs: build | |
environment: | |
name: 'Production' | |
url: ${{ steps.deploy-to-webapp.outputs.webapp-url }} | |
permissions: | |
id-token: write | |
steps: | |
- name: Download artifact from build job | |
uses: actions/download-artifact@v4 | |
with: | |
name: django-app | |
- name: Unzip artifact for deployment | |
run: unzip release.zip | |
- name: Login to Azure | |
uses: azure/login@v2 | |
with: | |
client-id: ${{ secrets.AZUREAPPSERVICE_CLIENTID_BA40A63595EE4D38BFA504607ABDE4DA }} | |
tenant-id: ${{ secrets.AZUREAPPSERVICE_TENANTID_C10B0DC527CC47CD8A44E6F209B1B8F2 }} | |
subscription-id: ${{ secrets.AZUREAPPSERVICE_SUBSCRIPTIONID_B8A1FE7890AC418AAFCB71BABC7E8488 }} | |
- name: 'Deploy to Azure Web App' | |
uses: azure/webapps-deploy@v3 | |
id: deploy-to-webapp | |
with: | |
app-name: 'yesalumni-morocco' | |
slot-name: 'Production' |