Skip to content

Commit ee8b1fb

Browse files
Harmanpreet-MicrosoftHarmanpreet Kaur
andauthored
chore : Enhance Repository Governance and Workflow Automation (microsoft#21)
* edit 1 * edit 2 * Repository Governance * added stale-bot * stalebot test * chNGED TO 1 DAY * edit 3 * edit1 * edit2 * edit 4 * edit 5 * edit 6 * edit 6 * edit 7 * edit 8 * edit 5 * edit 10 * edit 11 * edit 12 * edit 13 * Update stale-bot.yml * edit 14 * edit 15 * edit 16 * edit 17 * Update stale-bot.yml * Update CODEOWNER --------- Co-authored-by: Harmanpreet Kaur <[email protected]>
1 parent 097dba8 commit ee8b1fb

File tree

9 files changed

+340
-0
lines changed

9 files changed

+340
-0
lines changed
File renamed without changes.

.github/CODE_OF_CONDUCT.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# Microsoft Open Source Code of Conduct
2+
3+
This project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/).
4+
5+
Resources:
6+
7+
- [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/)
8+
- [Microsoft Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/)
9+
- Contact [[email protected]](mailto:[email protected]) with questions or concerns
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
---
2+
name: Bug report
3+
about: Create a report to help us improve
4+
title: ''
5+
labels: bug
6+
assignees: ''
7+
8+
---
9+
10+
# Describe the bug
11+
A clear and concise description of what the bug is.
12+
13+
# Expected behavior
14+
A clear and concise description of what you expected to happen.
15+
16+
# How does this bug make you feel?
17+
_Share a gif from [giphy](https://giphy.com/) to tells us how you'd feel_
18+
19+
---
20+
21+
# Debugging information
22+
23+
## Steps to reproduce
24+
Steps to reproduce the behavior:
25+
1. Go to '...'
26+
2. Click on '....'
27+
3. Scroll down to '....'
28+
4. See error
29+
30+
## Screenshots
31+
If applicable, add screenshots to help explain your problem.
32+
33+
## Logs
34+
35+
If applicable, add logs to help the engineer debug the problem.
36+
37+
---
38+
39+
# Tasks
40+
41+
_To be filled in by the engineer picking up the issue_
42+
43+
- [ ] Task 1
44+
- [ ] Task 2
45+
- [ ] ...
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
---
2+
name: Feature request
3+
about: Suggest an idea for this project
4+
title: ''
5+
labels: enhancement
6+
assignees: ''
7+
8+
---
9+
10+
# Motivation
11+
12+
A clear and concise description of why this feature would be useful and the value it would bring.
13+
Explain any alternatives considered and why they are not sufficient.
14+
15+
# How would you feel if this feature request was implemented?
16+
17+
_Share a gif from [giphy](https://giphy.com/) to tells us how you'd feel. Format: ![alt_text](https://media.giphy.com/media/xxx/giphy.gif)_
18+
19+
# Requirements
20+
21+
A list of requirements to consider this feature delivered
22+
- Requirement 1
23+
- Requirement 2
24+
- ...
25+
26+
# Tasks
27+
28+
_To be filled in by the engineer picking up the issue_
29+
30+
- [ ] Task 1
31+
- [ ] Task 2
32+
- [ ] ...

.github/ISSUE_TEMPLATE/subtask.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
---
2+
name: Sub task
3+
about: A sub task
4+
title: ''
5+
labels: subtask
6+
assignees: ''
7+
8+
---
9+
10+
Required by <link to parent issue>
11+
12+
# Description
13+
14+
A clear and concise description of what this subtask is.
15+
16+
# Tasks
17+
18+
_To be filled in by the engineer picking up the subtask
19+
20+
- [ ] Task 1
21+
- [ ] Task 2
22+
- [ ] ...

.github/PULL_REQUEST_TEMPLATE.md

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
## Purpose
2+
<!-- Describe the intention of the changes being proposed. What problem does it solve or functionality does it add? -->
3+
* ...
4+
5+
## Does this introduce a breaking change?
6+
<!-- Mark one with an "x". -->
7+
8+
- [ ] Yes
9+
- [ ] No
10+
11+
<!-- Please prefix your PR title with one of the following:
12+
* `feat`: A new feature
13+
* `fix`: A bug fix
14+
* `docs`: Documentation only changes
15+
* `style`: Changes that do not affect the meaning of the code (white-space, formatting, missing semi-colons, etc)
16+
* `refactor`: A code change that neither fixes a bug nor adds a feature
17+
* `perf`: A code change that improves performance
18+
* `test`: Adding missing tests or correcting existing tests
19+
* `build`: Changes that affect the build system or external dependencies (example scopes: gulp, broccoli, npm)
20+
* `ci`: Changes to our CI configuration files and scripts (example scopes: Travis, Circle, BrowserStack, SauceLabs)
21+
* `chore`: Other changes that don't modify src or test files
22+
* `revert`: Reverts a previous commit
23+
* !: A breaking change is indicated with a `!` after the listed prefixes above, e.g. `feat!`, `fix!`, `refactor!`, etc.
24+
-->
25+
26+
## How to Test
27+
* Get the code
28+
29+
```
30+
git clone [repo-address]
31+
cd [repo-name]
32+
git checkout [branch-name]
33+
npm install
34+
```
35+
36+
* Test the code
37+
<!-- Add steps to run the tests suite and/or manually test -->
38+
```
39+
```
40+
41+
## What to Check
42+
Verify that the following are valid
43+
* ...
44+
45+
## Other Information
46+
<!-- Add any other helpful information that may be needed here. -->

.github/workflows/CI.yml

Lines changed: 145 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,145 @@
1+
name: CI-Validate Deployment-Multi-Agent-Custom-Automation-Engine-Solution-Accelerator
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
schedule:
8+
- cron: '0 6,18 * * *' # Runs at 6:00 AM and 6:00 PM GMT
9+
10+
jobs:
11+
deploy:
12+
runs-on: ubuntu-latest
13+
steps:
14+
- name: Checkout Code
15+
uses: actions/checkout@v3
16+
17+
- name: Setup Azure CLI
18+
run: |
19+
curl -sL https://aka.ms/InstallAzureCLIDeb | sudo bash
20+
az --version # Verify installation
21+
22+
- name: Login to Azure
23+
run: |
24+
az login --service-principal -u ${{ secrets.AZURE_CLIENT_ID }} -p ${{ secrets.AZURE_CLIENT_SECRET }} --tenant ${{ secrets.AZURE_TENANT_ID }}
25+
26+
- name: Install Bicep CLI
27+
run: az bicep install
28+
29+
- name: Generate Resource Group Name
30+
id: generate_rg_name
31+
run: |
32+
TIMESTAMP=$(date +%Y%m%d%H%M%S)
33+
COMMON_PART="pslautomationRes"
34+
UNIQUE_RG_NAME="${COMMON_PART}${TIMESTAMP}"
35+
echo "RESOURCE_GROUP_NAME=${UNIQUE_RG_NAME}" >> $GITHUB_ENV
36+
37+
- name: Check and Create Resource Group
38+
id: check_create_rg
39+
run: |
40+
rg_exists=$(az group exists --name ${{ env.RESOURCE_GROUP_NAME }})
41+
if [ "$rg_exists" = "false" ]; then
42+
az group create --name ${{ env.RESOURCE_GROUP_NAME }} --location eastus2
43+
fi
44+
45+
- name: Generate Unique Solution Prefix
46+
id: generate_solution_prefix
47+
run: |
48+
COMMON_PART="pslr"
49+
TIMESTAMP=$(date +%s)
50+
UNIQUE_SOLUTION_PREFIX="${COMMON_PART}$(echo $TIMESTAMP | tail -c 3)"
51+
echo "SOLUTION_PREFIX=${UNIQUE_SOLUTION_PREFIX}" >> $GITHUB_ENV
52+
53+
- name: Deploy Bicep Template
54+
id: deploy
55+
run: |
56+
az deployment group create \
57+
--resource-group ${{ env.RESOURCE_GROUP_NAME }} \
58+
--template-file deploy/macae.bicep \
59+
--parameters prefix=${{ env.SOLUTION_PREFIX }} \
60+
--parameters azureOpenAILocation=westus \
61+
--parameters cosmosLocation=westus
62+
63+
- name: Retrieve Deployed OpenAI Resource Name
64+
id: get_openai_name
65+
run: |
66+
PREFIX="${{ env.SOLUTION_PREFIX }}-openai"
67+
RESOURCE_GROUP="${{ env.RESOURCE_GROUP_NAME }}"
68+
OPENAI_RESOURCE_NAME=$(az resource list --resource-group $RESOURCE_GROUP --query "[?contains(name, '$PREFIX')].name | [0]" -o tsv)
69+
if [ -z "$OPENAI_RESOURCE_NAME" ]; then
70+
echo "Failed to find the OpenAI resource in the resource group."
71+
exit 1
72+
fi
73+
echo "OPENAI_RESOURCE_NAME=${OPENAI_RESOURCE_NAME}" >> $GITHUB_ENV
74+
75+
- name: Use OpenAI Resource Name
76+
run: |
77+
echo "Deployed OpenAI Resource Name: ${{ env.OPENAI_RESOURCE_NAME }}"
78+
79+
- name: Delete Bicep Deployment
80+
if: success()
81+
run: |
82+
az group delete --name ${{ env.RESOURCE_GROUP_NAME }} --yes --no-wait
83+
84+
- name: Wait for resource deletion to complete
85+
run: |
86+
resources_to_check+=("${{ env.OPENAI_RESOURCE_NAME }}")
87+
echo "List of resources to check: ${resources_to_check[@]}"
88+
resource_list=$(az resource list --resource-group ${{ env.RESOURCE_GROUP_NAME }} --output yaml)
89+
max_retries=3
90+
retry_intervals=(60 120 140)
91+
retries=0
92+
while true; do
93+
resource_found=false
94+
for resource in "${resources_to_check[@]}"; do
95+
echo "Checking resource: $resource"
96+
if echo "$resource_list" | grep -q "name: $resource"; then
97+
echo "Resource '$resource' exists in the resource group."
98+
resource_found=true
99+
else
100+
echo "Resource '$resource' does not exist in the resource group."
101+
fi
102+
done
103+
if [ "$resource_found" = true ]; then
104+
retries=$((retries + 1))
105+
if [ "$retries" -ge "$max_retries" ]; then
106+
echo "Maximum retry attempts reached. Exiting."
107+
break
108+
else
109+
echo "Waiting for ${retry_intervals[$retries-1]} seconds before retrying..."
110+
sleep ${retry_intervals[$retries-1]}
111+
fi
112+
else
113+
echo "No resources found. Exiting."
114+
break
115+
fi
116+
done
117+
118+
- name: Purge OpenAI Resource
119+
if: success()
120+
run: |
121+
echo "Purging the OpenAI Resource..."
122+
if ! az resource delete --ids /subscriptions/${{ secrets.AZURE_SUBSCRIPTION_ID }}/providers/Microsoft.CognitiveServices/locations/westus/resourceGroups/${{ env.RESOURCE_GROUP_NAME }}/deletedAccounts/${{ env.OPENAI_RESOURCE_NAME }} --verbose; then
123+
echo "Failed to purge OpenAI resource: ${{ env.OPENAI_RESOURCE_NAME }}"
124+
else
125+
echo "Purged the OpenAI resource: ${{ env.OPENAI_RESOURCE_NAME }}"
126+
fi
127+
128+
- name: Send Notification on Failure
129+
if: failure()
130+
run: |
131+
132+
RUN_URL="https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}"
133+
134+
# Construct the email body
135+
EMAIL_BODY=$(cat <<EOF
136+
{
137+
"body": "<p>Dear Team,</p><p>We would like to inform you that the Multi-Agent-Custom-Automation-Engine-Solution-Accelerator 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>"
138+
}
139+
EOF
140+
)
141+
142+
# Send the notification
143+
curl -X POST "${{ secrets.LOGIC_APP_URL }}" \
144+
-H "Content-Type: application/json" \
145+
-d "$EMAIL_BODY" || echo "Failed to send notification"
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
name: "pr-title-checker"
2+
3+
on:
4+
pull_request_target:
5+
types:
6+
- opened
7+
- edited
8+
- synchronize
9+
merge_group:
10+
11+
permissions:
12+
pull-requests: read
13+
14+
jobs:
15+
main:
16+
name: Validate PR title
17+
runs-on: ubuntu-latest
18+
if: ${{ github.event_name != 'merge_group' }}
19+
steps:
20+
- uses: amannn/action-semantic-pull-request@v5
21+
env:
22+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/stale-bot.yml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
name: 'Close stale issues and PRs'
2+
on:
3+
schedule:
4+
- cron: '0 1 * * *'
5+
6+
permissions:
7+
contents: write
8+
issues: write
9+
pull-requests: write
10+
11+
jobs:
12+
stale:
13+
runs-on: ubuntu-latest
14+
steps:
15+
- uses: actions/stale@v9
16+
with:
17+
stale-issue-message: 'This issue is stale because it has been open 180 days with no activity. Remove stale label or comment or this will be closed in 30 days.'
18+
days-before-stale: 180
19+
days-before-close: 30

0 commit comments

Comments
 (0)