From 77fc1cba79d3379ffadc3fe1fbac4b2a74911001 Mon Sep 17 00:00:00 2001 From: Mostafa Kamal Date: Sat, 1 Jun 2024 02:00:01 +0600 Subject: [PATCH] ci/cd --- .github/workflows/deploy.yml | 58 +++++++++++++++++++----------------- 1 file changed, 31 insertions(+), 27 deletions(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 4b7038e..2361780 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -1,40 +1,44 @@ -name: Deploy Python project to Azure Function App +name: Deploy fastapi project to Azure Function App on: - [push] + push: + branches: + - main + workflow_dispatch: env: - AZURE_FUNCTIONAPP_NAME: 'fastapi-demo' # set this to your function app name on Azure - AZURE_FUNCTIONAPP_PACKAGE_PATH: '.' # set this to the path to your function app project, defaults to the repository root - PYTHON_VERSION: '3.11' # set this to the python version to use (e.g. '3.6', '3.7', '3.8') + AZURE_FUNCTIONAPP_NAME: 'fastapi-demo' # Set this to your function app name on Azure + AZURE_FUNCTIONAPP_PACKAGE_PATH: '.' # Set this to the path to your function app project, defaults to the repository root + PYTHON_VERSION: '3.11' # Set this to the python version to use (e.g. '3.6', '3.7', '3.8', '3.11') jobs: build-and-deploy: runs-on: ubuntu-latest environment: dev + steps: - - name: 'Checkout GitHub Action' - uses: actions/checkout@v3 + - name: 'Checkout GitHub Action' + uses: actions/checkout@v3 - - name: Setup Python ${{ env.PYTHON_VERSION }} Environment - uses: actions/setup-python@v4 - with: - python-version: ${{ env.PYTHON_VERSION }} + - 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: '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 }} - publish-profile: ${{ secrets.AZURE_FUNCTIONAPP_PUBLISH_PROFILE }} - scm-do-build-during-deployment: true - enable-oryx-build: true \ No newline at end of file + - 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 }} + publish-profile: ${{ secrets.AZURE_FUNCTIONAPP_PUBLISH_PROFILE }} + scm-do-build-during-deployment: true + enable-oryx-build: true