Skip to content

Commit

Permalink
Create deploy API.yml
Browse files Browse the repository at this point in the history
  • Loading branch information
TechPrototyper authored Apr 10, 2024
1 parent c67a985 commit b1825e5
Showing 1 changed file with 49 additions and 0 deletions.
49 changes: 49 additions & 0 deletions .github/workflows/deploy API.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# Tim Walter, 2024-03-31
# Deploy Python API for Chatbot Demo to Azure Function App
# Modified Github Action-Script taken from Microsoft Template Repository

name: Deploy Python API to Azure Function App

on:
[push]

env:
AZURE_FUNCTIONAPP_NAME: ${{ vars.AZURE_FUNCTIONAPP_NAME }} # TimW: Set Repo Variable to the Name if the Azure Function App we're deploaying to
AZURE_FUNCTIONAPP_PACKAGE_PATH: ${{ vars.AZURE_FUNCTIONAPP_PACKAGE_PATH }} # TimW: Function App is stored in the Repo where Variable points to
PYTHON_VERSION: '3.10' # Python version, in our case 3.10

jobs:
build-and-deploy:
runs-on: ubuntu-latest
# environment: dev # TimW: We aren't using any environment here but rather read varaibles and secrets straight from the repository
steps:
- name: 'Checkout GitHub Action'
uses: actions/checkout@v3

- name: 'Azure CLI login'
uses: azure/login@v1
with:
creds: ${{ secrets.AZURE_CREDENTIALS }} # TimW: Contains Azure Credential Object with Subscription ID, Tenant ID, Client ID, Client Secret taken from Repo Secrets

- name: Setup Python ${{ env.PYTHON_VERSION }} Environment
uses: actions/setup-python@v4
with:
python-version: ${{ env.PYTHON_VERSION }}

- name: 'Resolve Project Dependencies Using Pip'
shell: bash
run: |
pushd './${{ env.AZURE_FUNCTIONAPP_PACKAGE_PATH }}'
python -m pip install --upgrade pip
pip install -r requirements.txt --target=".python_packages/lib/site-packages"
popd
- name: 'Run Azure Functions Action'
uses: Azure/functions-action@v1
id: fa
with:
app-name: ${{ env.AZURE_FUNCTIONAPP_NAME }}
package: ${{ env.AZURE_FUNCTIONAPP_PACKAGE_PATH }} # TimW: See comments above
publish-profile: ${{ secrets.AZURE_FUNCTIONAPP_PUBLISH_PROFILE }} # TimW: Publishing Profile is a secret in the repository
scm-do-build-during-deployment: true
enable-oryx-build: true

0 comments on commit b1825e5

Please sign in to comment.