Skip to content

Commit c12643c

Browse files
workflows and codeowners added to accelerators
1 parent a0c4efb commit c12643c

File tree

10 files changed

+627
-0
lines changed

10 files changed

+627
-0
lines changed

.github/CODEOWNERS

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# Lines starting with '#' are comments.
2+
# Each line is a file pattern followed by one or more owners.
3+
4+
# These owners will be the default owners for everything in the repo.
5+
* @Avijit-Microsoft @Roopan-Microsoft @Prajwal-Microsoft
6+
7+
# Specific directory ownership
8+
/ClientAdvisor/ @Avijit-Microsoft @Roopan-Microsoft @Prajwal-Microsoft
9+
10+
/ResearchAssistant/ @Avijit-Microsoft @Roopan-Microsoft @Prajwal-Microsoft

.github/workflows/CAdeploy.yml

Lines changed: 130 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,130 @@
1+
name: CI-Validate Deployment-Client Advisor
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
paths:
8+
- 'ClientAdvisor/**'
9+
schedule:
10+
- cron: '0 6,18 * * *' # Runs at 6:00 AM and 6:00 PM GMT
11+
12+
jobs:
13+
deploy:
14+
runs-on: ubuntu-latest
15+
16+
steps:
17+
- name: Checkout Code
18+
uses: actions/checkout@v3
19+
20+
- name: Setup Azure CLI
21+
run: |
22+
curl -sL https://aka.ms/InstallAzureCLIDeb | sudo bash
23+
az --version # Verify installation
24+
25+
- name: Login to Azure
26+
run: |
27+
az login --service-principal -u ${{ secrets.AZURE_CLIENT_ID }} -p ${{ secrets.AZURE_CLIENT_SECRET }} --tenant ${{ secrets.AZURE_TENANT_ID }}
28+
29+
- name: Install Bicep CLI
30+
run: az bicep install
31+
32+
- name: Generate Resource Group Name
33+
id: generate_rg_name
34+
run: |
35+
echo "Generating a unique resource group name..."
36+
TIMESTAMP=$(date +%Y%m%d%H%M%S)
37+
COMMON_PART="pslautomationCli"
38+
UNIQUE_RG_NAME="${COMMON_PART}${TIMESTAMP}"
39+
echo "RESOURCE_GROUP_NAME=${UNIQUE_RG_NAME}" >> $GITHUB_ENV
40+
echo "Generated RESOURCE_GROUP_PREFIX: ${UNIQUE_RG_NAME}"
41+
42+
- name: Check and Create Resource Group
43+
id: check_create_rg
44+
run: |
45+
echo "RESOURCE_GROUP: ${{ env.RESOURCE_GROUP_NAME }}"
46+
set -e
47+
echo "Checking if resource group exists..."
48+
rg_exists=$(az group exists --name ${{ env.RESOURCE_GROUP_NAME }})
49+
if [ "$rg_exists" = "false" ]; then
50+
echo "Resource group does not exist. Creating..."
51+
az group create --name ${{ env.RESOURCE_GROUP_NAME }} --location uksouth || { echo "Error creating resource group"; exit 1; }
52+
else
53+
echo "Resource group already exists."
54+
fi
55+
56+
- name: Generate Unique Solution Prefix
57+
id: generate_solution_prefix
58+
run: |
59+
set -e
60+
COMMON_PART="pslc"
61+
TIMESTAMP=$(date +%s)
62+
UPDATED_TIMESTAMP=$(echo $TIMESTAMP | tail -c 3)
63+
UNIQUE_SOLUTION_PREFIX="${COMMON_PART}${UPDATED_TIMESTAMP}"
64+
echo "SOLUTION_PREFIX=${UNIQUE_SOLUTION_PREFIX}" >> $GITHUB_ENV
65+
echo "Generated SOLUTION_PREFIX: ${UNIQUE_SOLUTION_PREFIX}"
66+
67+
- name: Deploy Bicep Template
68+
id: deploy
69+
run: |
70+
set -e
71+
az deployment group create \
72+
--resource-group ${{ env.RESOURCE_GROUP_NAME }} \
73+
--template-file ClientAdvisor/Deployment/bicep/main.bicep \
74+
--parameters solutionPrefix=${{ env.SOLUTION_PREFIX }} cosmosLocation=eastus2
75+
76+
- name: Update PowerBI URL
77+
if: success()
78+
run: |
79+
set -e
80+
81+
COMMON_PART="-app-service"
82+
application_name="${{ env.SOLUTION_PREFIX }}${COMMON_PART}"
83+
echo "Updating application: $application_name"
84+
85+
# Log the Power BI URL being set
86+
echo "Setting Power BI URL: ${{ vars.VITE_POWERBI_EMBED_URL }}"
87+
88+
# Update the application settings
89+
az webapp config appsettings set --name "$application_name" --resource-group "${{ env.RESOURCE_GROUP_NAME }}" --settings VITE_POWERBI_EMBED_URL="${{ vars.VITE_POWERBI_EMBED_URL }}"
90+
91+
# Restart the web app
92+
az webapp restart --resource-group "${{ env.RESOURCE_GROUP_NAME }}" --name "$application_name"
93+
94+
echo "Power BI URL updated successfully for application: $application_name."
95+
96+
- name: Delete Bicep Deployment
97+
if: success()
98+
run: |
99+
set -e
100+
echo "Checking if resource group exists..."
101+
rg_exists=$(az group exists --name ${{ env.RESOURCE_GROUP_NAME }})
102+
if [ "$rg_exists" = "true" ]; then
103+
echo "Resource group exist. Cleaning..."
104+
az group delete \
105+
--name ${{ env.RESOURCE_GROUP_NAME }} \
106+
--yes \
107+
--no-wait
108+
echo "Resource group deleted... ${{ env.RESOURCE_GROUP_NAME }}"
109+
else
110+
echo "Resource group does not exists."
111+
fi
112+
113+
- name: Send Notification on Failure
114+
if: failure()
115+
run: |
116+
RUN_URL="https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}"
117+
118+
# Construct the email body
119+
EMAIL_BODY=$(cat <<EOF
120+
{
121+
"body": "<p>Dear Team,</p><p>We would like to inform you that the Client Advisor Automation process has encountered an issue and has failed to complete successfully.</p><p><strong>Build URL:</strong> ${RUN_URL}<br> ${OUTPUT}</p><p>Please investigate the matter at your earliest convenience.</p><p>Best regards,<br>Your Automation Team</p>"
122+
}
123+
EOF
124+
)
125+
126+
# Send the notification
127+
curl -X POST "${{ secrets.LOGIC_APP_URL }}" \
128+
-H "Content-Type: application/json" \
129+
-d "$EMAIL_BODY" || echo "Failed to send notification"
130+

.github/workflows/RAdeploy.yml

Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
name: CI-Validate Deployment-Research Assistant
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
paths:
8+
- 'ResearchAssistant/**'
9+
schedule:
10+
- cron: '0 6,18 * * *' # Runs at 6:00 AM and 6:00 PM GMT
11+
12+
jobs:
13+
deploy:
14+
runs-on: ubuntu-latest
15+
steps:
16+
- name: Checkout Code
17+
uses: actions/checkout@v3
18+
19+
- name: Setup Azure CLI
20+
run: |
21+
curl -sL https://aka.ms/InstallAzureCLIDeb | sudo bash
22+
az --version # Verify installation
23+
24+
- name: Login to Azure
25+
run: |
26+
az login --service-principal -u ${{ secrets.AZURE_CLIENT_ID }} -p ${{ secrets.AZURE_CLIENT_SECRET }} --tenant ${{ secrets.AZURE_TENANT_ID }}
27+
28+
- name: Install Bicep CLI
29+
run: az bicep install
30+
31+
- name: Generate Resource Group Name
32+
id: generate_rg_name
33+
run: |
34+
echo "Generating a unique resource group name..."
35+
TIMESTAMP=$(date +%Y%m%d%H%M%S)
36+
COMMON_PART="pslautomationRes"
37+
UNIQUE_RG_NAME="${COMMON_PART}${TIMESTAMP}"
38+
echo "RESOURCE_GROUP_NAME=${UNIQUE_RG_NAME}" >> $GITHUB_ENV
39+
echo "Generated Resource_GROUP_PREFIX: ${UNIQUE_RG_NAME}"
40+
41+
- name: Check and Create Resource Group
42+
id: check_create_rg
43+
run: |
44+
set -e
45+
echo "Checking if resource group exists..."
46+
rg_exists=$(az group exists --name ${{ env.RESOURCE_GROUP_NAME }})
47+
if [ "$rg_exists" = "false" ]; then
48+
echo "Resource group does not exist. Creating..."
49+
az group create --name ${{ env.RESOURCE_GROUP_NAME }} --location eastus2 || { echo "Error creating resource group"; exit 1; }
50+
else
51+
echo "Resource group already exists."
52+
fi
53+
54+
- name: Generate Unique Solution Prefix
55+
id: generate_solution_prefix
56+
run: |
57+
set -e
58+
COMMON_PART="pslr"
59+
TIMESTAMP=$(date +%s)
60+
UPDATED_TIMESTAMP=$(echo $TIMESTAMP | tail -c 3)
61+
UNIQUE_SOLUTION_PREFIX="${COMMON_PART}${UPDATED_TIMESTAMP}"
62+
echo "SOLUTION_PREFIX=${UNIQUE_SOLUTION_PREFIX}" >> $GITHUB_ENV
63+
echo "Generated SOLUTION_PREFIX: ${UNIQUE_SOLUTION_PREFIX}"
64+
65+
- name: Deploy Bicep Template
66+
id: deploy
67+
run: |
68+
set -e
69+
az deployment group create \
70+
--resource-group ${{ env.RESOURCE_GROUP_NAME }} \
71+
--template-file ResearchAssistant/Deployment/bicep/main.bicep \
72+
--parameters solutionPrefix=${{ env.SOLUTION_PREFIX }}
73+
74+
- name: Delete Bicep Deployment
75+
if: success()
76+
run: |
77+
set -e
78+
echo "Checking if resource group exists..."
79+
rg_exists=$(az group exists --name ${{ env.RESOURCE_GROUP_NAME }})
80+
if [ "$rg_exists" = "true" ]; then
81+
echo "Resource group exist. Cleaning..."
82+
az group delete \
83+
--name ${{ env.RESOURCE_GROUP_NAME }} \
84+
--yes \
85+
--no-wait
86+
echo "Resource group deleted... ${{ env.RESOURCE_GROUP_NAME }}"
87+
else
88+
echo "Resource group does not exists."
89+
fi
90+
91+
- name: Send Notification on Failure
92+
if: failure()
93+
run: |
94+
RUN_URL="https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}"
95+
96+
# Construct the email body
97+
EMAIL_BODY=$(cat <<EOF
98+
{
99+
"body": "<p>Dear Team,</p><p>We would like to inform you that the Research Assistant Automation process has encountered an issue and has failed to complete successfully.</p><p><strong>Build URL:</strong> ${RUN_URL}<br> ${OUTPUT}</p><p>Please investigate the matter at your earliest convenience.</p><p>Best regards,<br>Your Automation Team</p>"
100+
}
101+
EOF
102+
)
103+
104+
# Send the notification
105+
curl -X POST "${{ secrets.LOGIC_APP_URL }}" \
106+
-H "Content-Type: application/json" \
107+
-d "$EMAIL_BODY" || echo "Failed to send notification"
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
name: Build ClientAdvisor Docker Images
2+
3+
on:
4+
push:
5+
branches: [main]
6+
paths:
7+
- ClientAdvisor/**
8+
pull_request:
9+
branches: [main]
10+
types:
11+
- opened
12+
- ready_for_review
13+
- reopened
14+
- synchronize
15+
paths:
16+
- ClientAdvisor/**
17+
merge_group:
18+
19+
jobs:
20+
docker-build:
21+
strategy:
22+
matrix:
23+
include:
24+
- app_name: byc-wa-app
25+
dockerfile: ClientAdvisor/App/WebApp.Dockerfile
26+
password_secret: DOCKER_PASSWORD
27+
- app_name: byc-wa-fn
28+
dockerfile: ClientAdvisor/AzureFunction/Dockerfile
29+
password_secret: DOCKER_PASSWORD
30+
31+
uses: ./.github/workflows/build-docker.yml
32+
with:
33+
registry: bycwacontainerreg.azurecr.io
34+
username: bycwacontainerreg
35+
password_secret: ${{ matrix.password_secret }}
36+
app_name: ${{ matrix.app_name }}
37+
dockerfile: ${{ matrix.dockerfile }}
38+
push: true # Adjust this logic as necessary
39+
secrets: inherit

.github/workflows/build-docker.yml

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
name: Reusable Docker build and push workflow
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
registry:
7+
required: true
8+
type: string
9+
username:
10+
required: true
11+
type: string
12+
password_secret:
13+
required: true
14+
type: string
15+
app_name:
16+
required: true
17+
type: string
18+
dockerfile:
19+
required: true
20+
type: string
21+
push:
22+
required: true
23+
type: boolean
24+
secrets:
25+
DOCKER_PASSWORD:
26+
required: true
27+
28+
jobs:
29+
docker-build:
30+
runs-on: ubuntu-latest
31+
steps:
32+
33+
- name: Checkout
34+
uses: actions/checkout@v4
35+
36+
- name: Docker Login
37+
if: ${{ inputs.push }}
38+
uses: docker/login-action@v3
39+
with:
40+
registry: ${{ inputs.registry }}
41+
username: ${{ inputs.username }}
42+
password: ${{ secrets[inputs.password_secret] }}
43+
44+
- name: Set up Docker Buildx
45+
uses: docker/setup-buildx-action@v3
46+
47+
- name: Get current date
48+
id: date
49+
run: echo "date=$(date +'%Y-%m-%d')" >> $GITHUB_OUTPUT
50+
51+
- name: Build Docker Image and optionally push
52+
uses: docker/build-push-action@v6
53+
with:
54+
context: .
55+
file: ${{ inputs.dockerfile }}
56+
push: ${{ inputs.push }}
57+
cache-from: type=registry,ref=${{ inputs.registry }}/${{ inputs.app_name}}:latest
58+
tags: |
59+
${{ inputs.registry }}/${{ inputs.app_name}}:dev
60+
${{ inputs.registry }}/${{ inputs.app_name}}:${{ steps.date.outputs.date }}_${{ github.run_number }}
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
name: Build ResearchAssistant Docker Images
2+
3+
on:
4+
push:
5+
branches: [main]
6+
paths:
7+
- ResearchAssistant/**
8+
pull_request:
9+
branches: [main]
10+
types:
11+
- opened
12+
- ready_for_review
13+
- reopened
14+
- synchronize
15+
paths:
16+
- ResearchAssistant/**
17+
merge_group:
18+
19+
jobs:
20+
docker-build:
21+
strategy:
22+
matrix:
23+
include:
24+
- app_name: byoaia-app
25+
dockerfile: ResearchAssistant/App/WebApp.Dockerfile
26+
password_secret: DOCKER_PASSWORD_RESEARCHASSISTANT
27+
28+
uses: ./.github/workflows/build-docker.yml
29+
with:
30+
registry: byoaiacontainerreg.azurecr.io
31+
username: byoaiacontainerreg
32+
password_secret: ${{ matrix.password_secret }}
33+
app_name: ${{ matrix.app_name }}
34+
dockerfile: ${{ matrix.dockerfile }}
35+
push: true # Adjust this logic as necessary
36+
secrets: inherit

0 commit comments

Comments
 (0)