Skip to content

Commit 7fb234e

Browse files
authored
Merge pull request #1 from MicrosoftCloudEssentials-LearningHub/automations
automations - git pipelines
2 parents 1842bd3 + c22dfb0 commit 7fb234e

6 files changed

Lines changed: 157 additions & 9 deletions

File tree

.github/.markdownlint.json

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
"default": true,
3+
"MD005": false,
4+
"MD009": false,
5+
"MD013": false,
6+
"MD028": false,
7+
"MD029": false,
8+
"MD033": false,
9+
"MD048": false,
10+
"MD040": false,
11+
"MD041": false,
12+
"MD045": false,
13+
"MD046": false
14+
}
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
name: Update Last Modified Date
2+
3+
on:
4+
pull_request:
5+
branches:
6+
- main
7+
8+
permissions:
9+
contents: write
10+
11+
jobs:
12+
update-date:
13+
runs-on: ubuntu-latest
14+
15+
steps:
16+
- name: Checkout repository
17+
uses: actions/checkout@v4
18+
with:
19+
fetch-depth: 0
20+
21+
- name: Set up Python
22+
uses: actions/setup-python@v4
23+
with:
24+
python-version: '3.x'
25+
26+
- name: Install dependencies
27+
run: pip install python-dateutil
28+
29+
- name: Configure Git
30+
run: |
31+
git config --global user.email "github-actions[bot]@users.noreply.github.com"
32+
git config --global user.name "github-actions[bot]"
33+
34+
- name: Update last modified date in Markdown files
35+
run: python .github/workflows/update_date.py
36+
37+
- name: Commit changes
38+
run: |
39+
git add -A
40+
git commit -m "Update last modified date in Markdown files" || echo "No changes to commit"
41+
git push origin HEAD:${{ github.event.pull_request.head.ref }}

.github/workflows/update_date.py

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
import os
2+
import subprocess
3+
from datetime import datetime, timezone
4+
5+
# Get the list of modified files
6+
result = subprocess.run(['git', 'diff', '--name-only', 'HEAD~1'], stdout=subprocess.PIPE)
7+
modified_files = result.stdout.decode('utf-8').split()
8+
9+
# Debugging: Print the list of modified files
10+
print("Modified files:", modified_files)
11+
12+
# Filter for Markdown files
13+
modified_md_files = [f for f in modified_files if f.endswith('.md')]
14+
15+
# Debugging: Print the list of modified Markdown files
16+
print("Modified Markdown files:", modified_md_files)
17+
18+
# Current date
19+
current_date = datetime.now(timezone.utc).strftime('%Y-%m-%d')
20+
21+
# Function to update the last modified date in a file
22+
def update_date_in_file(file_path):
23+
with open(file_path, 'r') as file:
24+
lines = file.readlines()
25+
26+
updated = False
27+
with open(file_path, 'w') as file:
28+
for line in lines:
29+
if line.startswith('Last updated:'):
30+
file.write(f'Last updated: {current_date}\n')
31+
updated = True
32+
else:
33+
file.write(line)
34+
if not updated:
35+
file.write(f'\nLast updated: {current_date}\n')
36+
37+
# Check if there are any modified Markdown files
38+
if not modified_md_files:
39+
print("No modified Markdown files found.")
40+
exit(0)
41+
42+
# Update the date in each modified Markdown file
43+
for file_path in modified_md_files:
44+
print(f"Updating file: {file_path}") # Debugging: Print the file being updated
45+
update_date_in_file(file_path)
46+
47+
# Add and commit changes
48+
subprocess.run(['git', 'add', '-A'])
49+
subprocess.run(['git', 'commit', '-m', 'Update last modified date in Markdown files'])
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
name: Validate and Fix Markdown
2+
3+
on:
4+
pull_request:
5+
branches:
6+
- main
7+
8+
permissions:
9+
contents: write
10+
11+
jobs:
12+
validate-and-fix-markdown:
13+
runs-on: ubuntu-latest
14+
15+
steps:
16+
- name: Checkout repository
17+
uses: actions/checkout@v4
18+
with:
19+
fetch-depth: 0
20+
21+
- name: Set up Node.js
22+
uses: actions/setup-node@v3
23+
with:
24+
node-version: '16'
25+
26+
- name: Install Markdown Linter
27+
run: npm install -g markdownlint-cli
28+
29+
- name: Lint and Fix Markdown files
30+
run: markdownlint '**/*.md' --fix --config .github/.markdownlint.json --ignore GPT-RAG_SolutionAccelerator/
31+
32+
- name: Configure Git
33+
run: |
34+
git config --global user.email "github-actions[bot]@users.noreply.github.com"
35+
git config --global user.name "github-actions[bot]"
36+
37+
- name: Commit changes
38+
run: |
39+
git fetch origin
40+
git checkout -b ${{ github.event.pull_request.head.ref }} origin/${{ github.event.pull_request.head.ref }}
41+
git add -A
42+
git commit -m "Fix Markdown syntax issues" || echo "No changes to commit"
43+
git pull --rebase origin ${{ github.event.pull_request.head.ref }} || echo "No rebase needed"
44+
git push origin HEAD:${{ github.event.pull_request.head.ref }}

README.md

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ Last updated: 2025-05-13
2020

2121
</details>
2222

23-
2423
<details>
2524
<summary><b>Table of Content</b> (Click to expand)</summary>
2625

@@ -32,6 +31,7 @@ Last updated: 2025-05-13
3231
</details>
3332

3433
> When Autoscale IOPS is enabled for Azure Database for MySQL (Flexible Server), the IOPS (Input/Output Operations Per Second) automatically scale both up and down based on your workload demands. <br/>
34+
>
3535
> - During `high demand`, the system `increases IOPS` to maintain performance.
3636
> - During `low demand`, it `scales down` to reduce resource usage and cost.
3737
@@ -43,7 +43,7 @@ Last updated: 2025-05-13
4343
4. Choose your subscription, resource group, and server name.
4444
5. Select the region, MySQL version, and workload type (e.g., Development, Production).
4545

46-
https://github.com/user-attachments/assets/5b500aea-538d-4ddb-88b6-e0717a2d0fbe
46+
<https://github.com/user-attachments/assets/5b500aea-538d-4ddb-88b6-e0717a2d0fbe>
4747

4848
## How to enable IOPS (manual approach)
4949

@@ -53,7 +53,7 @@ Last updated: 2025-05-13
5353
4. In the IOPS section, select the option `Autoscale IOPS`
5454
5. Click `Save` to apply the changes.
5555

56-
https://github.com/user-attachments/assets/9e2983b3-3839-4ad3-8ab8-ccbb698f3228
56+
<https://github.com/user-attachments/assets/9e2983b3-3839-4ad3-8ab8-ccbb698f3228>
5757

5858
## How to enable IOPS (script)
5959

@@ -67,7 +67,7 @@ Last updated: 2025-05-13
6767

6868
<img width="550" alt="image" src="https://github.com/user-attachments/assets/f08afb04-e271-4ac3-8594-e3e98a9bfd2e" />
6969

70-
- Choose the ` Storage IO` metric (both percent and count).
70+
- Choose the `Storage IO` metric (both percent and count).
7171

7272
<img width="550" alt="image" src="https://github.com/user-attachments/assets/ca585f55-e943-413d-9477-f26c099a1e66" />
7373

@@ -82,11 +82,9 @@ Last updated: 2025-05-13
8282
- You can also monitor `IO utilization percentage` to see how close your server is to its current IOPS limit.
8383
3. **Enable Alerts (Optional)**: You can set up `alerts` in Azure Monitor to notify you when IOPS usage crosses certain thresholds, which can help you track scaling events in real time.
8484

85-
https://github.com/user-attachments/assets/19b96128-e37f-40b4-8e23-8a5384bc6686
86-
85+
<https://github.com/user-attachments/assets/19b96128-e37f-40b4-8e23-8a5384bc6686>
8786

8887
<div align="center">
8988
<h3 style="color: #4CAF50;">Total Visitors</h3>
9089
<img src="https://profile-counter.glitch.me/brown9804/count.svg" alt="Visitor Count" style="border: 2px solid #4CAF50; border-radius: 5px; padding: 5px;"/>
9190
</div>
92-

autoscaleMultiple-IOPS/README.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ Last updated: 2025-05-13
1212
> Using [Python 3.7+](https://www.python.org/downloads/source/)
1313
1414
> [!NOTE]
15-
> Enable Autoscale IOPS via REST API, as now this is the only way to automate enabling Autoscale IOPS since, Azure CLI and PowerShell do not support this setting yet.
15+
> Enable Autoscale IOPS via REST API, as now this is the only way to automate enabling Autoscale IOPS since, Azure CLI and PowerShell do not support this setting yet.
1616
1717
> [!IMPORTANT]
1818
> Autoscale IOPS is `only available` for the `General Purpose` and `Business Critical tiers`. `Burstable tier` (B-series) servers (e.g., B1ms) `do not support autoscale IOPS`.
@@ -23,13 +23,14 @@ Last updated: 2025-05-13
2323

2424
<img width="550" alt="image" src="https://github.com/user-attachments/assets/fa74f47c-bef2-4ad3-8b0f-2ee50813c486" />
2525

26-
- [Install Azure CLI](https://learn.microsoft.com/en-us/cli/azure/install-azure-cli).
26+
- [Install Azure CLI](https://learn.microsoft.com/en-us/cli/azure/install-azure-cli).
2727

2828
<img width="550" alt="image" src="https://github.com/user-attachments/assets/3f552ecc-8e07-453a-9655-8bb5a89e1791" />
2929

3030
## By Resource Group
3131

3232
> Overall process: <br/> (./scripts/enable_autoscale_iops_byRG.py)
33+
>
3334
> - Automatically retrieves your **Azure subscription ID** using the Azure CLI. <br/>
3435
> - List all Resource Groups in current subscription ID. <br/>
3536
> - Prompts you only for the **resource group name**. <br/>
@@ -45,6 +46,7 @@ Review [the script](./scripts/enable_autoscale_iops_byRG.py), and download it to
4546
## Across a Subscription
4647

4748
> You can also enable autoscale IOPS across an entire subscription, it requires: <br/>
49+
>
4850
> - Listing all MySQL Flexible Servers in the subscription. <br/>
4951
> - For each server, retrieving its resource group. <br/>
5052
> - Applying the update if the server is in a supported tier (General Purpose or Business Critical). <br/>

0 commit comments

Comments
 (0)