Skip to content

Commit fa8db60

Browse files
authored
Merge pull request #4 from MicrosoftCloudEssentials-LearningHub/changing-visit-counts
Changing visit counts
2 parents 80bd0a1 + e4df86c commit fa8db60

6 files changed

Lines changed: 151 additions & 15 deletions

File tree

.github/workflows/update-md-date.yml

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@ on:
77

88
permissions:
99
contents: write
10-
10+
pull-requests: write
11+
1112
jobs:
1213
update-date:
1314
runs-on: ubuntu-latest
@@ -30,12 +31,17 @@ jobs:
3031
run: |
3132
git config --global user.email "github-actions[bot]@users.noreply.github.com"
3233
git config --global user.name "github-actions[bot]"
33-
34+
3435
- name: Update last modified date in Markdown files
3536
run: python .github/workflows/update_date.py
3637

3738
- name: Commit changes
39+
env:
40+
TOKEN: ${{ secrets.GITHUB_TOKEN }}
3841
run: |
42+
git fetch origin
43+
git pull --rebase origin ${{ github.event.pull_request.head.ref }} || echo "No rebase needed"
3944
git add -A
4045
git commit -m "Update last modified date in Markdown files" || echo "No changes to commit"
46+
git remote set-url origin https://x-access-token:${TOKEN}@github.com/${{ github.repository }}
4147
git push origin HEAD:${{ github.event.pull_request.head.ref }}
Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
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+
25+
- name: Shallow clone visitor counter logic
26+
run: git clone --depth=1 https://github.com/brown9804/github-visitor-counter.git
27+
28+
- name: Set up Node.js
29+
uses: actions/setup-node@v4
30+
with:
31+
node-version: '20'
32+
33+
- name: Install dependencies for github-visitor-counter
34+
run: |
35+
cd github-visitor-counter
36+
npm ci
37+
38+
- name: Run visitor counter logic (updates markdown badges and metrics.json)
39+
run: node github-visitor-counter/update_repo_views_counter.js
40+
env:
41+
TRAFFIC_TOKEN: ${{ secrets.TRAFFIC_TOKEN }}
42+
REPO: ${{ github.repository }}
43+
44+
- name: Move generated metrics.json to root
45+
run: mv github-visitor-counter/metrics.json .
46+
47+
- name: List files for debugging
48+
run: |
49+
ls -l
50+
ls -l github-visitor-counter
51+
52+
- name: Clean up visitor counter logic
53+
run: rm -rf github-visitor-counter
54+
55+
- name: Configure Git author
56+
run: |
57+
git config --global user.name "github-actions[bot]"
58+
git config --global user.email "github-actions[bot]@users.noreply.github.com"
59+
60+
- name: Commit and push changes (PR)
61+
if: github.event_name == 'pull_request'
62+
env:
63+
TOKEN: ${{ secrets.GITHUB_TOKEN }}
64+
run: |
65+
git fetch origin
66+
git checkout -b ${{ github.event.pull_request.head.ref }} origin/${{ github.event.pull_request.head.ref }}
67+
git add "*.md" metrics.json
68+
git commit -m "Update visitor count" || echo "No changes to commit"
69+
git remote set-url origin https://x-access-token:${TOKEN}@github.com/${{ github.repository }}
70+
git pull --rebase origin ${{ github.event.pull_request.head.ref }} || echo "No rebase needed"
71+
git push origin HEAD:${{ github.event.pull_request.head.ref }}
72+
73+
- name: Commit and push changes (non-PR)
74+
if: github.event_name != 'pull_request'
75+
env:
76+
TOKEN: ${{ secrets.GITHUB_TOKEN }}
77+
run: |
78+
git fetch origin
79+
git checkout ${{ github.event.pull_request.head.ref }} || git checkout -b ${{ github.event.pull_request.head.ref }} origin/${{ github.event.pull_request.head.ref }}
80+
git add "*.md" metrics.json
81+
git commit -m "Update visitor count" || echo "No changes to commit"
82+
git remote set-url origin https://x-access-token:${TOKEN}@github.com/${{ github.repository }}
83+
git pull --rebase origin ${{ github.event.pull_request.head.ref }} || echo "No rebase needed"
84+
git push origin HEAD:${{ github.event.pull_request.head.ref }}
85+
86+
- name: Create Pull Request (non-PR)
87+
if: github.event_name != 'pull_request'
88+
uses: peter-evans/create-pull-request@v6
89+
with:
90+
token: ${{ secrets.GITHUB_TOKEN }}
91+
branch: update-visitor-count
92+
title: "Update visitor count"
93+
body: "Automated update of visitor count"
94+
base: main

.github/workflows/validate_and_fix_markdown.yml

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ on:
77

88
permissions:
99
contents: write
10+
pull-requests: write
1011

1112
jobs:
1213
validate-and-fix-markdown:
@@ -27,18 +28,18 @@ jobs:
2728
run: npm install -g markdownlint-cli
2829

2930
- name: Lint and Fix Markdown files
30-
run: markdownlint '**/*.md' --fix --config .github/.markdownlint.json --ignore GPT-RAG_SolutionAccelerator/
31+
run: markdownlint '**/*.md' --fix --config .github/.markdownlint.json
3132

3233
- name: Configure Git
3334
run: |
3435
git config --global user.email "github-actions[bot]@users.noreply.github.com"
3536
git config --global user.name "github-actions[bot]"
3637
37-
- name: Commit changes
38+
- name: Commit and rebase changes
39+
env:
40+
PR_BRANCH: ${{ github.head_ref || github.ref_name }}
3841
run: |
39-
git fetch origin
40-
git checkout -b ${{ github.event.pull_request.head.ref }} origin/${{ github.event.pull_request.head.ref }}
4142
git add -A
4243
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 }}
44+
git pull --rebase origin "$PR_BRANCH" || echo "No rebase needed"
45+
git push origin HEAD:"$PR_BRANCH"

README.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ Costa Rica
77
[![GitHub](https://img.shields.io/badge/--181717?logo=github&logoColor=ffffff)](https://github.com/)
88
[brown9804](https://github.com/brown9804)
99

10-
Last updated: 2025-05-13
10+
Last updated: 2025-07-16
1111

1212
----------
1313

@@ -87,7 +87,9 @@ Last updated: 2025-05-13
8787

8888
<https://github.com/user-attachments/assets/19b96128-e37f-40b4-8e23-8a5384bc6686>
8989

90+
<!-- START BADGE -->
9091
<div align="center">
91-
<h3 style="color: #4CAF50;">Total Visitors</h3>
92-
<img src="https://profile-counter.glitch.me/brown9804/count.svg" alt="Visitor Count" style="border: 2px solid #4CAF50; border-radius: 5px; padding: 5px;"/>
92+
<img src="https://img.shields.io/badge/Total%20views-1153-limegreen" alt="Total views">
93+
<p>Refresh Date: 2025-07-16</p>
9394
</div>
95+
<!-- END BADGE -->

autoscaleMultiple-IOPS/README.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ Costa Rica
55
[![GitHub](https://img.shields.io/badge/--181717?logo=github&logoColor=ffffff)](https://github.com/)
66
[brown9804](https://github.com/brown9804)
77

8-
Last updated: 2025-05-13
8+
Last updated: 2025-07-16
99

1010
----------
1111

@@ -21,7 +21,6 @@ Last updated: 2025-05-13
2121

2222
</details>
2323

24-
2524
> [!NOTE]
2625
> 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.
2726
@@ -74,7 +73,9 @@ Review [the script](./scripts/enable_autoscale_iops_across_subscription.py), and
7473
2. Make sure you're logged in: `az login`
7574
4. Run the script: `python {script-name}.py`
7675

76+
<!-- START BADGE -->
7777
<div align="center">
78-
<h3 style="color: #4CAF50;">Total Visitors</h3>
79-
<img src="https://profile-counter.glitch.me/brown9804/count.svg" alt="Visitor Count" style="border: 2px solid #4CAF50; border-radius: 5px; padding: 5px;"/>
78+
<img src="https://img.shields.io/badge/Total%20views-1153-limegreen" alt="Total views">
79+
<p>Refresh Date: 2025-07-16</p>
8080
</div>
81+
<!-- END BADGE -->

metrics.json

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
[
2+
{
3+
"date": "2025-07-07",
4+
"count": 330,
5+
"uniques": 20
6+
},
7+
{
8+
"date": "2025-07-08",
9+
"count": 159,
10+
"uniques": 6
11+
},
12+
{
13+
"date": "2025-07-10",
14+
"count": 482,
15+
"uniques": 1
16+
},
17+
{
18+
"date": "2025-07-11",
19+
"count": 170,
20+
"uniques": 4
21+
},
22+
{
23+
"date": "2025-07-12",
24+
"count": 7,
25+
"uniques": 1
26+
},
27+
{
28+
"date": "2025-07-14",
29+
"count": 4,
30+
"uniques": 1
31+
}
32+
]

0 commit comments

Comments
 (0)