|
| 1 | +# Docs for the Azure Web Apps Deploy action: https://github.com/Azure/webapps-deploy |
| 2 | +# More GitHub Actions for Azure: https://github.com/Azure/actions |
| 3 | +# More info on Python, GitHub Actions, and Azure App Service: https://aka.ms/python-webapps-actions |
| 4 | + |
| 5 | +name: Build and deploy Python app to Azure Web App - fast-api-reference |
| 6 | + |
| 7 | +on: |
| 8 | + pull_request: |
| 9 | + types: [closed] |
| 10 | + branches: |
| 11 | + - main |
| 12 | + workflow_dispatch: |
| 13 | + |
| 14 | +jobs: |
| 15 | + build: |
| 16 | + runs-on: ubuntu-latest |
| 17 | + permissions: |
| 18 | + contents: read #This is required for actions/checkout |
| 19 | + |
| 20 | + steps: |
| 21 | + - uses: actions/checkout@v4 |
| 22 | + |
| 23 | + - name: Download npm |
| 24 | + uses: actions/setup-python@v5 |
| 25 | + with: |
| 26 | + python-version: '3.13' |
| 27 | + |
| 28 | + - name: Set up Python version |
| 29 | + uses: actions/setup-python@v5 |
| 30 | + with: |
| 31 | + python-version: '3.13' |
| 32 | + |
| 33 | + - name: Create and start virtual environment |
| 34 | + run: | |
| 35 | + cd backend |
| 36 | + python -m venv venv |
| 37 | + source venv/bin/activate |
| 38 | + |
| 39 | + - name: Install dependencies |
| 40 | + run: | |
| 41 | + cd backend |
| 42 | + pip install -r requirements.txt |
| 43 | + |
| 44 | + - name: Install Node dependencies |
| 45 | + run: | |
| 46 | + cd frontend |
| 47 | + npm install |
| 48 | + |
| 49 | + - name: Build Frontend |
| 50 | + run: | |
| 51 | + cd frontend |
| 52 | + npm run build |
| 53 | +
|
| 54 | + - name: Zip artifact for deployment |
| 55 | + run: | |
| 56 | + cd backend |
| 57 | + zip -r ../release.zip ./* |
| 58 | +
|
| 59 | + - name: Upload artifact for deployment jobs |
| 60 | + uses: actions/upload-artifact@v4 |
| 61 | + with: |
| 62 | + name: python-app |
| 63 | + path: | |
| 64 | + release.zip |
| 65 | + !venv/ |
| 66 | +
|
| 67 | + deploy: |
| 68 | + runs-on: ubuntu-latest |
| 69 | + needs: build |
| 70 | + environment: |
| 71 | + name: 'Production' |
| 72 | + url: ${{ steps.deploy-to-webapp.outputs.webapp-url }} |
| 73 | + permissions: |
| 74 | + id-token: write #This is required for requesting the JWT |
| 75 | + contents: read #This is required for actions/checkout |
| 76 | + |
| 77 | + steps: |
| 78 | + - name: Download artifact from build job |
| 79 | + uses: actions/download-artifact@v4 |
| 80 | + with: |
| 81 | + name: python-app |
| 82 | + |
| 83 | + - name: Unzip artifact for deployment |
| 84 | + run: unzip release.zip |
| 85 | + |
| 86 | + |
| 87 | + - name: Login to Azure |
| 88 | + uses: azure/login@v2 |
| 89 | + with: |
| 90 | + client-id: ${{ secrets.AZUREAPPSERVICE_CLIENTID_07118B6326EE492693A4582BDAE9294E }} |
| 91 | + tenant-id: ${{ secrets.AZUREAPPSERVICE_TENANTID_98091920E4D5432E9786AA6ADFC34B54 }} |
| 92 | + subscription-id: ${{ secrets.AZUREAPPSERVICE_SUBSCRIPTIONID_7BFCF659655641B8987A25BBEF11D64A }} |
| 93 | + |
| 94 | + - name: 'Deploy to Azure Web App' |
| 95 | + uses: azure/webapps-deploy@v3 |
| 96 | + id: deploy-to-webapp |
| 97 | + with: |
| 98 | + app-name: 'fast-api-reference' |
| 99 | + slot-name: 'Production' |
| 100 | + |
0 commit comments