1
- name : Build, Deploy, and Document Python App
1
+ name : Build, Deploy Python App to Azure , and Document with Flan-T5
2
2
3
3
on :
4
4
push :
5
5
branches :
6
- - main # Or your default branch
7
- workflow_dispatch : # Allows manual triggering
6
+ - main # Or your default branch (e.g., master)
7
+ workflow_dispatch : # Allows manual triggering from the Actions tab
8
8
9
9
env :
10
- PYTHON_VERSION : ' 3.9'
11
- # AZURE_APP_NAME and AZURE_RESOURCE_GROUP are set from secrets for security/config
12
- CODE_TO_DOCUMENT_PATH : ' app' # Relative path to the code you want to document
13
-
10
+ PYTHON_VERSION : ' 3.9' # Define Python version for consistency
11
+ # AZURE_APP_NAME and AZURE_RESOURCE_GROUP are set from secrets for the deployment step
12
+ CODE_TO_DOCUMENT_PATH : ' app' # Relative path in your repo to the Python code you want to document
13
+ # HF_MODEL_ID will be set in the documentation job's environment
14
+
14
15
jobs :
15
16
build-deploy-document :
16
17
runs-on : ubuntu-latest
18
+ # Optional: if you set up environments in GitHub for different stages
19
+ # environment: production
20
+
17
21
steps :
18
- - name : Checkout repository
19
- uses : actions/checkout@v4
22
+ - name : Checkout repository
23
+ uses : actions/checkout@v4
24
+
25
+ - name : Set up Python ${{ env.PYTHON_VERSION }}
26
+ uses : actions/setup-python@v5
27
+ with :
28
+ python-version : ${{ env.PYTHON_VERSION }}
20
29
21
- - name : Set up Python ${{ env.PYTHON_VERSION }}
22
- uses : actions/setup-python@v5
23
- with :
24
- python-version : ${{ env.PYTHON_VERSION }}
30
+ - name : Install dependencies
31
+ run : |
32
+ python -m pip install --upgrade pip
33
+ pip install -r requirements.txt # Ensure requirements.txt includes flask, gunicorn, requests
25
34
26
- - name : Install dependencies
27
- run : |
28
- python -m pip install --upgrade pip
29
- pip install -r requirements.txt
35
+ - name : Zip App for Azure deployment
36
+ # This zips the 'app' directory and 'requirements.txt' into deploy.zip
37
+ # App Service for Python will run `pip install -r requirements.txt` from the zip root.
38
+ run : |
39
+ echo "Zipping application files..."
40
+ zip -r deploy.zip . -i '${{ env.CODE_TO_DOCUMENT_PATH }}/*' 'requirements.txt'
41
+ echo "Contents of deploy.zip:"
42
+ unzip -l deploy.zip # List contents to verify
30
43
31
- - name : Zip App for deployment
32
- # This zips the 'app' directory and 'requirements.txt' into deploy.zip
33
- # App Service for Python will run `pip install -r requirements.txt` from the zip root.
34
- run : |
35
- zip -r deploy.zip . -i 'app/*' 'requirements.txt'
36
- # If you have files in root: zip -r deploy.zip app requirements.txt *.py
37
- # The key is requirements.txt should be at the root of the zip for App Service build.
44
+ - name : Login to Azure
45
+ uses : azure/login@v1
46
+ with :
47
+ creds : ${{ secrets.AZURE_CREDENTIALS }} # Secret containing the JSON output of `az ad sp create-for-rbac`
38
48
39
- - name : Login to Azure
40
- uses : azure/login@v1
41
- with :
42
- creds : ${{ secrets.AZURE_CREDENTIALS }}
49
+ - name : Deploy to Azure Web App
50
+ id : deploy-to-azure # Give this step an ID to access its outputs if needed
51
+ uses : azure/webapps-deploy@v2
52
+ with :
53
+ app-name : ${{ secrets.AZURE_APP_NAME }}
54
+ resource-group-name : ${{ secrets.AZURE_RESOURCE_GROUP }} # Often not strictly needed if app-name is globally unique
55
+ package : deploy.zip
56
+ # slot-name: 'production' # Optional: if using deployment slots
43
57
58
+ - name : Output Azure Web App URL
59
+ run : echo "App deployed to https://${{ steps.deploy-to-azure.outputs.webapp-url }}"
44
60
45
- - name : Deploy to Azure Web App # Example for Azure secrets
46
- uses : azure/webapps-deploy@v2
47
- with :
48
- app-name : ${{ secrets.AZURE_APP_NAME }}
49
- resource-group-name : ${{ secrets.AZURE_RESOURCE_GROUP }}
50
- package : deploy.zip
51
- # The azure/login action uses secrets.AZURE_CREDENTIALS
61
+ - name : Generate and Publish Documentation with Flan-T5
62
+ env :
63
+ # Hugging Face API Credentials
64
+ HF_API_TOKEN : ${{ secrets.HF_API_TOKEN }}
65
+ HF_MODEL_ID : " google/flan-t5-base" # Or "google/flan-t5-large", "google/flan-t5-small" etc.
66
+ # Choose based on desired quality vs. speed/rate limits.
52
67
53
- - name : Generate and Publish Documentation
54
- env :
55
- # These environment variables are set for the 'run' command below
56
- OPENAI_API_KEY : ${{ secrets.OPENAI_API_KEY }}
57
- CONFLUENCE_URL : ${{ secrets.CONFLUENCE_URL }}
58
- CONFLUENCE_EMAIL : ${{ secrets.CONFLUENCE_EMAIL }}
59
- CONFLUENCE_API_TOKEN : ${{ secrets.CONfluence_API_TOKEN }} # Corrected case from previous examples if it was wrong
60
- CONFLUENCE_SPACE_KEY : ${{ secrets.CONFLUENCE_SPACE_KEY }}
61
- ROOT_DOC_TITLE : " ${{ github.repository }} - Project Docs"
62
- CODE_ROOT_PATH : " app"
63
- GITHUB_WORKSPACE : ${{ github.workspace }}
64
- run : python scripts/doc_generator.py
68
+ # Confluence Credentials
69
+ CONFLUENCE_URL : ${{ secrets.CONFLUENCE_URL }}
70
+ CONFLUENCE_EMAIL : ${{ secrets.CONFLUENCE_EMAIL }}
71
+ CONFLUENCE_API_TOKEN : ${{ secrets.CONFLUENCE_API_TOKEN }}
72
+ CONFLUENCE_SPACE_KEY : ${{ secrets.CONFLUENCE_SPACE_KEY }}
73
+
74
+ # Documentation Structure
75
+ ROOT_DOC_TITLE : " ${{ github.repository }} - HF Flan-T5 Docs" # e.g., "yourusername/your-repo - HF Flan-T5 Docs"
76
+ CODE_ROOT_PATH : ${{ env.CODE_TO_DOCUMENT_PATH }} # Using the global env var 'app'
77
+ GITHUB_WORKSPACE : ${{ github.workspace }} # Automatically provided by Actions, used by doc_generator.py
78
+ run : |
79
+ echo "Starting documentation generation script..."
80
+ python scripts/doc_generator.py
65
81
66
- - name : Azure Logout
67
- run : |
68
- az logout
69
- az cache purge
70
- az account clear
71
- if : always()
82
+ - name : Azure Logout
83
+ # Optional: good practice if other Azure CLI steps followed or if runner might be reused in complex scenarios
84
+ run : |
85
+ az logout
86
+ az cache purge
87
+ az account clear
88
+ if : always() # Run this even if previous steps fail (to ensure cleanup)
0 commit comments