Skip to content

Commit e49a562

Browse files
authored
Merge pull request #3 from MicrosoftCloudEssentials-LearningHub/adjusting-pipelines-visitscounter
Adjusting pipelines visitscounter
2 parents a2332f4 + d096ca7 commit e49a562

File tree

6 files changed

+150
-13
lines changed

6 files changed

+150
-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: 6 additions & 5 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:
@@ -34,11 +35,11 @@ jobs:
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: 7 additions & 5 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-06-06
11+
Last updated: 2025-07-16
1212

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

@@ -58,7 +58,6 @@ Last updated: 2025-06-06
5858

5959
</details>
6060

61-
6261
> How to extract layout elements from PDFs stored in an Azure Storage Account, process them using Azure Document Intelligence, and store the results in Cosmos DB for further analysis.
6362
>
6463
> 1. Upload your PDFs to an Azure Blob Storage container. <br/>
@@ -78,6 +77,7 @@ Last updated: 2025-06-06
7877

7978
> [!NOTE]
8079
> Azure Event Grid System Topics are free to create and manage, a System Topic is automatically created and managed by Azure for certain Azure services that emit events. It represents a source of events from an Azure resource (like a Storage Account, Key Vault, or Azure Maps). `You don't need to create or manage the topic yourself, Azure does it for you when you enable event publishing on a supported resource.` <br/>
80+
>
8181
> - Emits predefined event types (e.g., Microsoft.Storage.BlobCreated, Microsoft.Resources.ResourceWriteSuccess). <br/>
8282
> - You can attach event handlers (like Azure Functions, Logic Apps, Webhooks) to respond to these events. <br/>
8383
> - Works seamlessly with serverless architectures for real-time automation. <br/>
@@ -176,6 +176,7 @@ Last updated: 2025-06-06
176176
> 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.
177177
178178
> [!TIP]
179+
>
179180
> - `Scale to Zero`: Indicates whether the service can automatically scale down to zero instances when idle.
180181
> - **IDLE** stands for:
181182
> - **I** – Inactive
@@ -189,7 +190,6 @@ Last updated: 2025-06-06
189190
> - `Max Scale Out (Instances)`: Maximum number of instances the service can scale out to.
190191
> - `Example AI Use Cases`: Real-world scenarios where each plan excels.
191192
192-
193193
<details>
194194
<summary><strong>Flex Consumption</strong></summary>
195195

@@ -438,7 +438,9 @@ Last updated: 2025-06-06
438438

439439
<img width="550" alt="image" src="https://github.com/user-attachments/assets/27309a6d-c654-4c76-bbc1-990a9338973c">
440440

441+
<!-- START BADGE -->
441442
<div align="center">
442-
<h3 style="color: #4CAF50;">Total Visitors</h3>
443-
<img src="https://profile-counter.glitch.me/brown9804/count.svg" alt="Visitor Count" style="border: 2px solid #4CAF50; border-radius: 5px; padding: 5px;"/>
443+
<img src="https://img.shields.io/badge/Total%20views-55-limegreen" alt="Total views">
444+
<p>Refresh Date: 2025-07-16</p>
444445
</div>
446+
<!-- 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+
]

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-06-04
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-55-limegreen" alt="Total views">
113+
<p>Refresh Date: 2025-07-16</p>
113114
</div>
115+
<!-- END BADGE -->

0 commit comments

Comments
 (0)