Skip to content

Commit

Permalink
webapp deploy workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
jcamachor committed Feb 9, 2024
1 parent 11ab1ea commit 26d7ce2
Showing 1 changed file with 102 additions and 0 deletions.
102 changes: 102 additions & 0 deletions .github/workflows/webapp-deploy.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
# Copyright (c) Microsoft Corporation.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# 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 Python app to Azure Web App - lst-bench

on:
pull_request:
push:
paths:
- metrics/**
branches:
- main
workflow_dispatch:

permissions:
contents: read

env:
AZURE_WEBAPP_NAME: lst-bench
WORKING_DIRECTORY: './metrics/app'

jobs:
build:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- name: 'Set up Python version'
uses: actions/setup-python@v1
with:
python-version: '3.11'

- name: 'Create and start virtual environment'
working-directory: ${{ env.WORKING_DIRECTORY }}
run: |
python -m venv venv
source venv/bin/activate
- name: 'Install dependencies'
working-directory: ${{ env.WORKING_DIRECTORY }}
run: |
pip install setuptools
pip install -r requirements.txt
- name: Zip artifact for deployment
working-directory: ${{ env.WORKING_DIRECTORY }}
run: zip release.zip ./* -r

- name: Upload artifact for deployment jobs
uses: actions/upload-artifact@v3
with:
name: python-app
path: |
${{ env.WORKING_DIRECTORY }}/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 #This is required for requesting the JWT

steps:
- name: Download artifact from build job
uses: actions/download-artifact@v3
with:
name: python-app

- name: Unzip artifact for deployment
run: unzip release.zip

- name: Login to Azure
uses: azure/login@v1
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
id: deploy-to-webapp
with:
app-name: ${{ env.AZURE_WEBAPP_NAME }}

0 comments on commit 26d7ce2

Please sign in to comment.