From fa782bb1f1e805648368e41e794d5a8e2dbb9b7f Mon Sep 17 00:00:00 2001 From: Mostafa Kamal Date: Sun, 19 May 2024 01:59:23 +0600 Subject: [PATCH] github action --- .github/workflows/azure-functions-deploy.yml | 40 ++++++++++++++++++++ fastapi_project/api/root_index.py | 2 +- 2 files changed, 41 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/azure-functions-deploy.yml diff --git a/.github/workflows/azure-functions-deploy.yml b/.github/workflows/azure-functions-deploy.yml new file mode 100644 index 0000000..3392bb7 --- /dev/null +++ b/.github/workflows/azure-functions-deploy.yml @@ -0,0 +1,40 @@ +name: Deploy Azure Function App + +on: + push: + branches: + - main # Trigger deployment on push to the main branch + workflow_dispatch: # Allow manual trigger from the Actions tab + +jobs: + build-and-deploy: + runs-on: ubuntu-latest + + steps: + - name: Checkout repository + uses: actions/checkout@v2 + + - name: Set up Python + uses: actions/setup-python@v4 + with: + python-version: '3.9' # Specify the Python version + + - name: Create virtual environment + run: python3 -m venv .azure_function_fastapi_venv + + - name: Activate virtual environment and install dependencies + run: | + source .azure_function_fastapi_venv/bin/activate + python -m pip install --upgrade pip + pip install -r requirements.txt + + - name: Azure Login + uses: azure/login@v1 + with: + creds: ${{ secrets.AZURE_CREDENTIALS }} + + - name: Deploy to Azure Function App + uses: azure/functions-action@v1 + with: + app-name: ${{ secrets.PROJECT_NAME }} # Replace with your Function App name + package: '.' # Specify the directory to deploy, usually the current directory diff --git a/fastapi_project/api/root_index.py b/fastapi_project/api/root_index.py index 26dfeb4..f64b425 100644 --- a/fastapi_project/api/root_index.py +++ b/fastapi_project/api/root_index.py @@ -8,7 +8,7 @@ @router.get("/") async def root_index(request: Request): data = { - 'message': 'azure function project is running' + 'message': 'azure function project is running.' } return JSONResponse(content=data, status_code=status.HTTP_200_OK) \ No newline at end of file