Skip to content

Commit

Permalink
Add GitHub Actions workflow for Azure deployment
Browse files Browse the repository at this point in the history
  • Loading branch information
AhsenTahir committed Nov 8, 2024
1 parent ddf1cc4 commit 6e1361c
Showing 1 changed file with 71 additions and 0 deletions.
71 changes: 71 additions & 0 deletions .github/workflows/azure-deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
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')

0 comments on commit 6e1361c

Please sign in to comment.