Skip to content

Commit 29366c8

Browse files
authored
Merge pull request #6 from MicrosoftCloudEssentials-LearningHub/adjusting-pipelines-visitscounter
Adjusting pipelines visitscounter
2 parents b06c8d6 + ae6fc32 commit 29366c8

File tree

6 files changed

+155
-13
lines changed

6 files changed

+155
-13
lines changed

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

Lines changed: 6 additions & 0 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
update-date:
@@ -35,7 +36,12 @@ jobs:
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 ${{ github.event.pull_request.head.ref }}
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: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ Costa Rica
88
[![GitHub](https://img.shields.io/badge/--181717?logo=github&logoColor=ffffff)](https://github.com/)
99
[brown9804](https://github.com/brown9804)
1010

11-
Last updated: 2025-05-20
11+
Last updated: 2025-07-16
1212

1313
----------
1414

@@ -151,6 +151,7 @@ Last updated: 2025-05-20
151151
> In the context of Azure Function Apps, a `hosting option refers to the plan you choose to run your function app`. This choice affects how your function app is scaled, the resources available to each function app instance, and the support for advanced functionalities like virtual network connectivity and container support.
152152
153153
> [!TIP]
154+
>
154155
> - `Scale to Zero`: Indicates whether the service can automatically scale down to zero instances when idle.
155156
> - **IDLE** stands for:
156157
> - **I** – Inactive
@@ -164,7 +165,6 @@ Last updated: 2025-05-20
164165
> - `Max Scale Out (Instances)`: Maximum number of instances the service can scale out to.
165166
> - `Example AI Use Cases`: Real-world scenarios where each plan excels.
166167
167-
168168
<details>
169169
<summary><strong>Flex Consumption</strong></summary>
170170

@@ -731,7 +731,9 @@ If you need further assistance with the code, please click [here to view all the
731731

732732
<img width="550" alt="image" src="https://github.com/user-attachments/assets/28bba46b-eaf0-4bbc-a565-f7c1ad8a0ac6">
733733

734+
<!-- START BADGE -->
734735
<div align="center">
735-
<h3 style="color: #4CAF50;">Total Visitors</h3>
736-
<img src="https://profile-counter.glitch.me/brown9804/count.svg" alt="Visitor Count" style="border: 2px solid #4CAF50; border-radius: 5px; padding: 5px;"/>
736+
<img src="https://img.shields.io/badge/Total%20views-10-limegreen" alt="Total views">
737+
<p>Refresh Date: 2025-07-16</p>
737738
</div>
739+
<!-- 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+
]

terraform-infrastructure/README.md

Lines changed: 5 additions & 3 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-20
8+
Last updated: 2025-07-16
99

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

@@ -107,7 +107,9 @@ graph TD;
107107

108108
<img width="550" alt="image" src="https://github.com/user-attachments/assets/f2089d03-3a3d-431d-b462-8148ef519104">
109109

110+
<!-- START BADGE -->
110111
<div align="center">
111-
<h3 style="color: #4CAF50;">Total Visitors</h3>
112-
<img src="https://profile-counter.glitch.me/brown9804/count.svg" alt="Visitor Count" style="border: 2px solid #4CAF50; border-radius: 5px; padding: 5px;"/>
112+
<img src="https://img.shields.io/badge/Total%20views-10-limegreen" alt="Total views">
113+
<p>Refresh Date: 2025-07-16</p>
113114
</div>
115+
<!-- END BADGE -->

0 commit comments

Comments
 (0)