Trigger redeployment #6
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 - TrendXbtc | |
on: | |
push: | |
branches: | |
- main # This triggers the workflow on every push to the main branch | |
workflow_dispatch: # Allows you to manually trigger the workflow | |
jobs: | |
build: | |
runs-on: ubuntu-latest # Running on Ubuntu Linux | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 # Checks out the code from the repository | |
- name: Set up Python version | |
uses: actions/setup-python@v5 | |
with: | |
python-version: '3.11' # Set Python version to 3.11 | |
- name: Create and start virtual environment | |
run: | | |
python -m venv venv | |
source venv/bin/activate | |
- name: Install dependencies | |
run: pip install -r requirements.txt # Installs Python dependencies | |
- name: Zip artifact for deployment | |
run: zip release.zip ./* -r # Zips the project files for deployment | |
- name: Upload artifact for deployment jobs | |
uses: actions/upload-artifact@v4 | |
with: | |
name: python-app | |
path: | | |
release.zip | |
!venv/ # Don't upload the virtual environment | |
deploy: | |
runs-on: ubuntu-latest | |
needs: build # This job will run after the 'build' job | |
environment: | |
name: 'Production' | |
url: ${{ steps.deploy-to-webapp.outputs.webapp-url }} # URL of the deployed app | |
permissions: | |
id-token: write # Required to request the JWT for authentication | |
steps: | |
- name: Download artifact from build job | |
uses: actions/download-artifact@v4 | |
with: | |
name: python-app # Download the artifact created by the 'build' job | |
- name: Unzip artifact for deployment | |
run: unzip release.zip # Unzips the artifact | |
- name: Login to Azure | |
uses: azure/login@v2 # Logs into Azure | |
with: | |
client-id: ${{ secrets.AZURE_CLIENT_ID }} | |
tenant-id: ${{ secrets.AZURE_TENANT_ID }} | |
subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }} | |
- name: Deploy to Azure Web App | |
uses: azure/webapps-deploy@v3 # Deploys to Azure Web App | |
id: deploy-to-webapp | |
with: | |
app-name: 'TrendXbtc' # Your Azure Web App name | |
slot-name: 'Production' # Deployment slot (usually 'Production') |