Deploy Azure Function #7
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Deploy Azure Function | |
| on: | |
| push: | |
| branches: | |
| - main | |
| paths: | |
| - 'azure_webhook/**' | |
| - 'moon_reader/**' | |
| workflow_dispatch: | |
| env: | |
| PYTHON_VERSION: '3.14' | |
| jobs: | |
| build-and-deploy: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - name: Install uv | |
| uses: astral-sh/setup-uv@v5 | |
| - name: Setup Python ${{ env.PYTHON_VERSION }} | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: ${{ env.PYTHON_VERSION }} | |
| - name: Build dependencies | |
| shell: bash | |
| run: | | |
| cd azure_webhook | |
| # Install all dependencies including the local moon_reader into the deployment package | |
| uv pip install --target=".python_packages/lib/site-packages" . | |
| # Clean up any cached files to reduce deployment size | |
| find .python_packages -type d -name "__pycache__" -exec rm -rf {} + || true | |
| - name: Create ZIP Deployment Package | |
| shell: bash | |
| run: | | |
| cd azure_webhook | |
| zip -r ../deploy.zip . -x "wheels/*" "requirements.txt" | |
| - name: Deploy via REST API | |
| shell: bash | |
| run: | | |
| PUBLISH_URL=$(echo '${{ secrets.AZURE_FUNCTIONAPP_PUBLISH_PROFILE }}' | grep -o 'publishUrl="[^"]*"' | head -1 | cut -d '"' -f 2) | |
| USER_NAME=$(echo '${{ secrets.AZURE_FUNCTIONAPP_PUBLISH_PROFILE }}' | grep -o 'userName="[^"]*"' | head -1 | cut -d '"' -f 2) | |
| USER_PASS=$(echo '${{ secrets.AZURE_FUNCTIONAPP_PUBLISH_PROFILE }}' | grep -o 'userPWD="[^"]*"' | head -1 | cut -d '"' -f 2) | |
| echo "Deploying to https://$PUBLISH_URL/api/zipdeploy" | |
| curl -X POST -u "$USER_NAME:$USER_PASS" \ | |
| --data-binary @"deploy.zip" \ | |
| "https://$PUBLISH_URL/api/zipdeploy" |