Skip to content

Commit 924c880

Browse files
author
Harmanpreet Kaur
committed
Enhance CI workflows: update paths for Docker build, deploy, PyLint, and test workflows; upgrade action versions
1 parent 8420eae commit 924c880

4 files changed

Lines changed: 91 additions & 30 deletions

File tree

.github/workflows/build-docker-images.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,12 @@ on:
77
- dev
88
- demo
99
- hotfix
10+
paths:
11+
- 'src/backend/**'
12+
- 'src/frontend/**'
13+
- 'docker/**'
14+
- '.github/workflows/build-docker-images.yml'
15+
- '.github/workflows/build-docker.yml'
1016
pull_request:
1117
branches:
1218
- main
@@ -18,6 +24,12 @@ on:
1824
- ready_for_review
1925
- reopened
2026
- synchronize
27+
paths:
28+
- 'src/backend/**'
29+
- 'src/frontend/**'
30+
- 'docker/**'
31+
- '.github/workflows/build-docker-images.yml'
32+
- '.github/workflows/build-docker.yml'
2133
merge_group:
2234
workflow_dispatch:
2335

.github/workflows/deploy.yml

Lines changed: 50 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,19 @@
11
name: Deploy-Test-Cleanup Pipeline
22

33
on:
4-
workflow_run:
5-
workflows: ["Build Docker and Optional Push"]
6-
types:
7-
- completed
8-
branches:
9-
- main
10-
- dev
11-
- demo
12-
schedule:
13-
- cron: '0 5,17 * * *' # Runs at 5:00 AM and 5:00 PM GMT
14-
workflow_dispatch:
4+
push:
5+
branches:
6+
- main
7+
- dev
8+
- demo
9+
paths:
10+
- 'infra/**'
11+
- 'scripts/**'
12+
- 'azure.yaml'
13+
- '.github/workflows/deploy.yml'
14+
schedule:
15+
- cron: '0 5,17 * * *' # Runs at 5:00 AM and 5:00 PM GMT
16+
workflow_dispatch:
1517

1618
env:
1719
GPT_MIN_CAPACITY: 150
@@ -25,7 +27,7 @@ jobs:
2527
WEBAPP_URL: ${{ steps.get_output.outputs.WEBAPP_URL }}
2628
steps:
2729
- name: Checkout Code
28-
uses: actions/checkout@v3
30+
uses: actions/checkout@v5
2931

3032
- name: Setup Azure CLI
3133
run: |
@@ -43,7 +45,6 @@ jobs:
4345
export AZURE_TENANT_ID=${{ secrets.AZURE_TENANT_ID }}
4446
export AZURE_CLIENT_SECRET=${{ secrets.AZURE_CLIENT_SECRET }}
4547
export AZURE_SUBSCRIPTION_ID="${{ secrets.AZURE_SUBSCRIPTION_ID }}"
46-
export GPT_MIN_CAPACITY="${{ env.GPT_MIN_CAPACITY }}"
4748
export AZURE_REGIONS="${{ vars.AZURE_REGIONS }}"
4849
chmod +x scripts/checkquota.sh
4950
if ! scripts/checkquota.sh; then
@@ -72,6 +73,11 @@ jobs:
7273
- name: Fail Pipeline if Quota Check Fails
7374
if: env.QUOTA_FAILED == 'true'
7475
run: exit 1
76+
77+
- name: Set Deployment Region
78+
run: |
79+
echo "Selected Region: $VALID_REGION"
80+
echo "AZURE_LOCATION=$VALID_REGION" >> $GITHUB_ENV
7581
7682
- name: Install Bicep CLI
7783
run: az bicep install
@@ -94,7 +100,7 @@ jobs:
94100
rg_exists=$(az group exists --name ${{ env.RESOURCE_GROUP_NAME }})
95101
if [ "$rg_exists" = "false" ]; then
96102
echo "Resource group does not exist. Creating..."
97-
az group create --name ${{ env.RESOURCE_GROUP_NAME }} --location northcentralus || { echo "Error creating resource group"; exit 1; }
103+
az group create --name ${{ env.RESOURCE_GROUP_NAME }} --location australiaeast || { echo "Error creating resource group"; exit 1; }
98104
else
99105
echo "Resource group already exists."
100106
fi
@@ -126,17 +132,20 @@ jobs:
126132
IMAGE_TAG="latest"
127133
fi
128134
135+
# Generate current timestamp in desired format: YYYY-MM-DDTHH:MM:SS.SSSSSSSZ
136+
current_date=$(date -u +"%Y-%m-%dT%H:%M:%S.%7NZ")
137+
129138
az deployment group create \
130139
--name ${{ env.SOLUTION_PREFIX }}-deployment \
131140
--resource-group ${{ env.RESOURCE_GROUP_NAME }} \
132141
--template-file infra/main.bicep \
133142
--parameters \
134143
solutionName="${{ env.SOLUTION_PREFIX }}" \
135-
aiDeploymentsLocation="eastus" \
136-
useWafAlignedArchitecture=false \
137-
capacity=${{ env.GPT_MIN_CAPACITY }} \
144+
azureAiServiceLocation='${{ env.AZURE_LOCATION }}' \
138145
imageVersion="${IMAGE_TAG}" \
139-
createdBy="Pipeline"
146+
createdBy="Pipeline" \
147+
tags="{'SecurityControl':'Ignore','Purpose':'Deploying and Cleaning Up Resources for Validation','CreatedDate':'$current_date'}"
148+
140149
- name: Assign Contributor role to Service Principal
141150
if: always()
142151
run: |
@@ -185,7 +194,26 @@ jobs:
185194
186195
- name: Login to Azure
187196
run: |
188-
az login --service-principal -u ${{ secrets.AZURE_CLIENT_ID }} -p ${{ secrets.AZURE_CLIENT_SECRET }} --tenant ${{ secrets.AZURE_TENANT_ID }}
197+
az login --service-principal -u ${{ secrets.AZURE_CLIENT_ID }} -p ${{ secrets.AZURE_CLIENT_SECRET }} --tenant ${{ secrets.AZURE_TENANT_ID }}
198+
az account set --subscription "${{ secrets.AZURE_SUBSCRIPTION_ID }}"
199+
200+
- name: Assign Contributor role to Service Principal
201+
if: always()
202+
run: |
203+
echo "Assigning Contributor role to SPN for RG: ${{ env.RESOURCE_GROUP_NAME }}"
204+
az role assignment create \
205+
--assignee ${{ secrets.AZURE_CLIENT_ID }} \
206+
--role "Contributor" \
207+
--scope /subscriptions/${{ secrets.AZURE_SUBSCRIPTION_ID }}/resourceGroups/${{ env.RESOURCE_GROUP_NAME }}
208+
209+
echo "Assigning Log Analytics Contributor role for Log Analytics workspace access at RG level..."
210+
az role assignment create \
211+
--assignee ${{ secrets.AZURE_CLIENT_ID }} \
212+
--role "Log Analytics Reader" \
213+
--scope /subscriptions/${{ secrets.AZURE_SUBSCRIPTION_ID }}/resourceGroups/${{ env.RESOURCE_GROUP_NAME }} || echo "Log Analytics Contributor role assignment failed (may already exist)"
214+
215+
echo "Waiting for role assignment propagation..."
216+
sleep 30
189217
190218
- name: Get Log Analytics Workspace and OpenAI from Resource Group
191219
if: always()
@@ -356,7 +384,7 @@ jobs:
356384
357385
# Purge OpenAI Resource
358386
echo "Purging the OpenAI Resource..."
359-
if ! az resource delete --ids /subscriptions/${{ secrets.AZURE_SUBSCRIPTION_ID }}/providers/Microsoft.CognitiveServices/locations/northcentralus/resourceGroups/${{ env.RESOURCE_GROUP_NAME }}/deletedAccounts/${{ env.OPENAI_RESOURCE_NAME }} --verbose; then
387+
if ! az resource delete --ids /subscriptions/${{ secrets.AZURE_SUBSCRIPTION_ID }}/providers/Microsoft.CognitiveServices/locations/australiaeast/resourceGroups/${{ env.RESOURCE_GROUP_NAME }}/deletedAccounts/${{ env.OPENAI_RESOURCE_NAME }} --verbose; then
360388
echo "Failed to purge openai resource: ${{ env.OPENAI_RESOURCE_NAME }}"
361389
else
362390
echo "Purged the openai resource: ${{ env.OPENAI_RESOURCE_NAME }}"
@@ -399,7 +427,7 @@ jobs:
399427
400428
EMAIL_BODY=$(cat <<EOF
401429
{
402-
"body": "<p>Dear Team,</p><p>We would like to inform you that the DocGen Deployment Automation process has encountered an issue and has failed to complete successfully.</p><p><strong>Build URL:</strong> <a href=\"${RUN_URL}\">${RUN_URL}</a><br></p><p>Please investigate the matter at your earliest convenience.</p><p>Best regards,<br>Your Automation Team</p>"
430+
"body": "<p>Dear Team,</p><p>We would like to inform you that the CodeMod Deployment Automation process has encountered an issue and has failed to complete successfully.</p><p><strong>Build URL:</strong> <a href=\"${RUN_URL}\">${RUN_URL}</a><br></p><p>Please investigate the matter at your earliest convenience.</p><p>Best regards,<br>Your Automation Team</p>"
403431
}
404432
EOF
405433
)
@@ -412,4 +440,4 @@ jobs:
412440
if: always()
413441
run: |
414442
az logout
415-
echo "Logged out from Azure."
443+
echo "Logged out from Azure."

.github/workflows/pylint.yml

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,16 @@
11
name: PyLint
22

3-
on: [push]
3+
on:
4+
push:
5+
paths:
6+
- '**/*.py'
7+
- '**/.flake8'
8+
- '.github/workflows/pylint.yml'
9+
pull_request:
10+
paths:
11+
- '**/*.py'
12+
- '**/.flake8'
13+
- '.github/workflows/pylint.yml'
414

515
jobs:
616
lint:
@@ -12,11 +22,11 @@ jobs:
1222
steps:
1323
# Step 1: Checkout code
1424
- name: Checkout code
15-
uses: actions/checkout@v4
25+
uses: actions/checkout@v5
1626

1727
# Step 2: Set up Python environment
1828
- name: Set up Python ${{ matrix.python-version }}
19-
uses: actions/setup-python@v3
29+
uses: actions/setup-python@v6
2030
with:
2131
python-version: ${{ matrix.python-version }}
2232

.github/workflows/test.yml

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,12 @@ on:
66
- main
77
- dev
88
- demo
9+
paths:
10+
- 'src/backend/**/*.py'
11+
- 'src/tests/backend/**'
12+
- '.github/workflows/test.yml'
13+
- 'src/backend/requirements.txt'
14+
- 'src/backend/pyproject.toml'
915
pull_request:
1016
types:
1117
- opened
@@ -16,14 +22,20 @@ on:
1622
- main
1723
- dev
1824
- demo
25+
paths:
26+
- 'src/backend/**/*.py'
27+
- 'src/tests/backend/**'
28+
- '.github/workflows/test.yml'
29+
- 'src/backend/requirements.txt'
30+
- 'src/backend/pyproject.toml'
1931

2032
jobs:
2133
# frontend_tests:
2234
# runs-on: ubuntu-latest
2335

2436
# steps:
2537
# - name: Checkout code
26-
# uses: actions/checkout@v3
38+
# uses: actions/checkout@v5
2739

2840
# - name: Set up Node.js
2941
# uses: actions/setup-node@v3
@@ -64,18 +76,17 @@ jobs:
6476

6577
steps:
6678
- name: Checkout code
67-
uses: actions/checkout@v3
79+
uses: actions/checkout@v5
6880

6981
- name: Set up Python
70-
uses: actions/setup-python@v4
82+
uses: actions/setup-python@v6
7183
with:
7284
python-version: '3.11'
7385

7486
- name: Install Backend Dependencies
7587
run: |
7688
python -m pip install --upgrade pip
7789
pip install -r src/backend/requirements.txt
78-
pip install -r src/frontend/requirements.txt
7990
pip install pytest-cov
8091
pip install pytest-asyncio
8192
- name: Set PYTHONPATH
@@ -103,4 +114,4 @@ jobs:
103114
- name: Skip Backend Tests
104115
if: env.skip_backend_tests == 'true'
105116
run: |
106-
echo "Skipping backend tests because no test files were found."
117+
echo "Skipping backend tests because no test files were found."

0 commit comments

Comments
 (0)