Skip to content

Commit 08c2c28

Browse files
authored
Merge pull request #2 from MicrosoftCloudEssentials-LearningHub/logic-counter
counter pipeline - testing
2 parents 45c20df + eb0abce commit 08c2c28

File tree

6 files changed

+129
-6
lines changed

6 files changed

+129
-6
lines changed
Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
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+
# Commit and push logic for PR events (merge, not rebase)
61+
- name: Commit and push changes (PR)
62+
if: github.event_name == 'pull_request'
63+
env:
64+
TOKEN: ${{ secrets.GITHUB_TOKEN }}
65+
run: |
66+
git fetch origin
67+
git checkout ${{ github.head_ref }}
68+
git pull origin ${{ github.head_ref }} || echo "No merge needed"
69+
git add -A
70+
git commit -m "Update visitor count" || echo "No changes to commit"
71+
git remote set-url origin https://x-access-token:${TOKEN}@github.com/${{ github.repository }}
72+
git push origin HEAD:${{ github.head_ref }}
73+
74+
# Commit and push logic for non-PR events (merge, not rebase)
75+
- name: Commit and push changes (non-PR)
76+
if: github.event_name != 'pull_request'
77+
env:
78+
TOKEN: ${{ secrets.GITHUB_TOKEN }}
79+
run: |
80+
git fetch origin
81+
git checkout ${{ github.ref_name }} || git checkout -b ${{ github.ref_name }} origin/${{ github.ref_name }}
82+
git pull origin ${{ github.ref_name }} || echo "No merge needed"
83+
git add -A
84+
git commit -m "Update visitor count" || echo "No changes to commit"
85+
git remote set-url origin https://x-access-token:${TOKEN}@github.com/${{ github.repository }}
86+
git push origin HEAD:${{ github.ref_name }}

0-Energy_Hardware_Optimization.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,7 @@ az aks update -g ResourceGroup -n EfficientAKS --enable-cluster-autoscaler --min
270270

271271
<!-- START BADGE -->
272272
<div align="center">
273-
<img src="https://img.shields.io/badge/Total%20views-1341-limegreen" alt="Total views">
274-
<p>Refresh Date: 2025-08-18</p>
273+
<img src="https://img.shields.io/badge/Total%20views-52-limegreen" alt="Total views">
274+
<p>Refresh Date: 2025-08-20</p>
275275
</div>
276276
<!-- END BADGE -->

1-Cloud_k8s_Scaling.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1285,7 +1285,7 @@ foreach ($vm in $vmList) {
12851285
12861286
<!-- START BADGE -->
12871287
<div align="center">
1288-
<img src="https://img.shields.io/badge/Total%20views-1-limegreen" alt="Total views">
1288+
<img src="https://img.shields.io/badge/Total%20views-52-limegreen" alt="Total views">
12891289
<p>Refresh Date: 2025-08-20</p>
12901290
</div>
12911291
<!-- END BADGE -->

2-Azure_Stack_Architecture.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1065,7 +1065,7 @@ Layer Interactions:
10651065

10661066
<!-- START BADGE -->
10671067
<div align="center">
1068-
<img src="https://img.shields.io/badge/Total%20views-1-limegreen" alt="Total views">
1068+
<img src="https://img.shields.io/badge/Total%20views-52-limegreen" alt="Total views">
10691069
<p>Refresh Date: 2025-08-20</p>
10701070
</div>
10711071
<!-- END BADGE -->

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1280,7 +1280,7 @@ From [K8s cluster components](https://kubernetes.io/docs/concepts/architecture/)
12801280
12811281
<!-- START BADGE -->
12821282
<div align="center">
1283-
<img src="https://img.shields.io/badge/Total%20views-1341-limegreen" alt="Total views">
1284-
<p>Refresh Date: 2025-08-18</p>
1283+
<img src="https://img.shields.io/badge/Total%20views-52-limegreen" alt="Total views">
1284+
<p>Refresh Date: 2025-08-20</p>
12851285
</div>
12861286
<!-- END BADGE -->

metrics.json

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
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": 130,
30+
"uniques": 2
31+
},
32+
{
33+
"date": "2025-07-15",
34+
"count": 2,
35+
"uniques": 1
36+
}
37+
]

0 commit comments

Comments
 (0)