Skip to content

Commit 586df2b

Browse files
authored
Merge pull request #1 from MicrosoftCloudEssentials-LearningHub/IaC-AIvision-enhanc
IaC -> AI Vision enhancement
2 parents e15bd94 + b604693 commit 586df2b

20 files changed

+1998
-2
lines changed

.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: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
name: Update Last Modified Date
2+
3+
on:
4+
pull_request:
5+
branches:
6+
- main
7+
8+
permissions:
9+
contents: write
10+
pull-requests: write
11+
12+
jobs:
13+
update-date:
14+
runs-on: ubuntu-latest
15+
16+
steps:
17+
- name: Checkout repository
18+
uses: actions/checkout@v4
19+
with:
20+
fetch-depth: 0
21+
ref: ${{ github.head_ref || github.ref_name }}
22+
23+
- name: Set up Python
24+
uses: actions/setup-python@v4
25+
with:
26+
python-version: '3.x'
27+
28+
- name: Install dependencies
29+
run: pip install python-dateutil
30+
31+
- name: Configure Git
32+
run: |
33+
git config --global user.email "github-actions[bot]@users.noreply.github.com"
34+
git config --global user.name "github-actions[bot]"
35+
36+
- name: Update last modified date in Markdown files
37+
run: python .github/workflows/update_date.py
38+
39+
- name: Commit and merge changes
40+
env:
41+
PR_BRANCH: ${{ github.head_ref || github.ref_name }}
42+
GIT_AUTHOR_NAME: github-actions[bot]
43+
GIT_AUTHOR_EMAIL: github-actions[bot]@users.noreply.github.com
44+
GIT_COMMITTER_NAME: github-actions[bot]
45+
GIT_COMMITTER_EMAIL: github-actions[bot]@users.noreply.github.com
46+
run: |
47+
# Ensure we're on the correct branch
48+
git switch -c "$PR_BRANCH" || git switch "$PR_BRANCH"
49+
50+
# Stage and commit all changes (new, modified, deleted)
51+
git add -A
52+
git diff --staged --quiet || git commit -m "Update last modified date in Markdown files"
53+
54+
# Pull and merge existing changes from remote
55+
git pull origin "$PR_BRANCH" --no-rebase
56+
57+
# Push all changes to the PR branch
58+
git push origin "$PR_BRANCH"

.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: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
name: Use Visitor Counter Logic
2+
3+
on:
4+
pull_request:
5+
branches:
6+
- main
7+
schedule:
8+
- cron: '0 0 * * *' # Runs daily at midnight
9+
workflow_dispatch: # Allows manual triggering
10+
11+
permissions:
12+
contents: write
13+
pull-requests: write
14+
15+
jobs:
16+
update-visitor-count:
17+
runs-on: ubuntu-latest
18+
19+
steps:
20+
- name: Checkout current repository
21+
uses: actions/checkout@v4
22+
with:
23+
fetch-depth: 0
24+
ref: ${{ github.head_ref || github.ref_name }}
25+
26+
- name: Shallow clone visitor counter logic
27+
run: git clone --depth=1 https://github.com/brown9804/github-visitor-counter.git
28+
29+
- name: Set up Node.js
30+
uses: actions/setup-node@v4
31+
with:
32+
node-version: '20'
33+
34+
- name: Install dependencies for github-visitor-counter
35+
run: |
36+
cd github-visitor-counter
37+
npm ci
38+
39+
- name: Run visitor counter logic (updates markdown badges and metrics.json)
40+
run: node github-visitor-counter/update_repo_views_counter.js
41+
env:
42+
TRAFFIC_TOKEN: ${{ secrets.TRAFFIC_TOKEN }}
43+
REPO: ${{ github.repository }}
44+
45+
- name: Move generated metrics.json to root
46+
run: mv github-visitor-counter/metrics.json .
47+
48+
- name: List files for debugging
49+
run: |
50+
ls -l
51+
ls -l github-visitor-counter
52+
53+
- name: Clean up visitor counter logic
54+
run: rm -rf github-visitor-counter
55+
56+
- name: Configure Git author
57+
run: |
58+
git config --global user.name "github-actions[bot]"
59+
git config --global user.email "github-actions[bot]@users.noreply.github.com"
60+
61+
- name: Commit and merge changes
62+
env:
63+
PR_BRANCH: ${{ github.head_ref || github.ref_name }}
64+
GIT_AUTHOR_NAME: github-actions[bot]
65+
GIT_AUTHOR_EMAIL: github-actions[bot]@users.noreply.github.com
66+
GIT_COMMITTER_NAME: github-actions[bot]
67+
GIT_COMMITTER_EMAIL: github-actions[bot]@users.noreply.github.com
68+
run: |
69+
# Ensure we're on the correct branch
70+
git switch -c "$PR_BRANCH" || git switch "$PR_BRANCH"
71+
72+
# Stage and commit changes if any
73+
git add -A
74+
git diff --staged --quiet || git commit -m "Update visitor count"
75+
76+
# Pull and merge existing changes
77+
git pull origin "$PR_BRANCH" --no-rebase
78+
79+
# Push all changes
80+
git push origin "$PR_BRANCH"
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
name: Validate and Fix Markdown
2+
3+
on:
4+
pull_request:
5+
branches:
6+
- main
7+
8+
permissions:
9+
contents: write
10+
pull-requests: write
11+
12+
jobs:
13+
validate-and-fix-markdown:
14+
runs-on: ubuntu-latest
15+
16+
steps:
17+
- name: Checkout repository
18+
uses: actions/checkout@v4
19+
with:
20+
fetch-depth: 0
21+
ref: ${{ github.head_ref || github.ref_name }}
22+
23+
- name: Set up Node.js
24+
uses: actions/setup-node@v3
25+
with:
26+
node-version: '16'
27+
28+
- name: Install Markdown Linter
29+
run: npm install -g markdownlint-cli
30+
31+
- name: Lint and Fix Markdown files
32+
run: markdownlint '**/*.md' --fix --config .github/.markdownlint.json
33+
34+
- name: Configure Git
35+
run: |
36+
git config --global user.email "github-actions[bot]@users.noreply.github.com"
37+
git config --global user.name "github-actions[bot]"
38+
39+
- name: Commit and merge changes
40+
env:
41+
PR_BRANCH: ${{ github.head_ref || github.ref_name }}
42+
GIT_AUTHOR_NAME: github-actions[bot]
43+
GIT_AUTHOR_EMAIL: github-actions[bot]@users.noreply.github.com
44+
GIT_COMMITTER_NAME: github-actions[bot]
45+
GIT_COMMITTER_EMAIL: github-actions[bot]@users.noreply.github.com
46+
run: |
47+
# Ensure we're on the correct branch
48+
git switch -c "$PR_BRANCH" || git switch "$PR_BRANCH"
49+
50+
# Stage and commit changes if any
51+
git add -A
52+
git diff --staged --quiet || git commit -m "Fix Markdown syntax issues"
53+
54+
# Pull and merge existing changes
55+
git pull origin "$PR_BRANCH" --no-rebase
56+
57+
# Push all changes
58+
git push origin "$PR_BRANCH"

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
# .tfstate files
55
*.tfstate
66
*.tfstate.*
7+
.terraform.lock.hcl
8+
terraform.tfstate.backup
79

810
# Crash log files
911
crash.log

0 commit comments

Comments
 (0)