Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
134 changes: 134 additions & 0 deletions .github/scripts/update_repo_views_counter.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
const fs = require('fs');
const path = require('path');

const REPO = process.env.REPO;
const GITHUB_TOKEN = process.env.TRAFFIC_TOKEN;
const METRICS_FILE = 'metrics.json';

if (!GITHUB_TOKEN || !REPO) {
console.error('Error: TRAFFIC_TOKEN and REPO environment variables must be set.');
process.exit(1);
}

if (typeof fetch !== 'function') {
console.error('Error: global fetch is not available. Use Node.js 20 or later.');
process.exit(1);
}

async function getLast14DaysTraffic() {
const response = await fetch(`https://api.github.com/repos/${REPO}/traffic/views`, {
headers: {
Accept: 'application/vnd.github+json',
Authorization: `Bearer ${GITHUB_TOKEN}`,
'User-Agent': 'visitor-counter'
}
});

if (!response.ok) {
const errorText = await response.text();
throw new Error(
`Failed to fetch traffic data: ${response.status} ${response.statusText}\n${errorText}`
);
}

const data = await response.json();
return data.views.map((item) => ({
date: item.timestamp.slice(0, 10),
count: item.count,
uniques: item.uniques
}));
}

function readMetrics() {
if (!fs.existsSync(METRICS_FILE)) {
return [];
}

try {
const raw = fs.readFileSync(METRICS_FILE, 'utf-8');
const parsed = JSON.parse(raw);
return Array.isArray(parsed) ? parsed : [];
} catch {
console.error('metrics.json is not valid JSON. Starting fresh.');
return [];
}
}

function writeMetrics(metrics) {
fs.writeFileSync(METRICS_FILE, JSON.stringify(metrics, null, 2));
console.log(`metrics.json updated with ${metrics.length} days`);
}

function mergeMetrics(existing, fetched) {
const byDate = new Map();

for (const entry of existing) {
byDate.set(entry.date, entry);
}

for (const entry of fetched) {
byDate.set(entry.date, entry);
}

return [...byDate.values()].sort((left, right) => left.date.localeCompare(right.date));
}

function calculateTotalViews(metrics) {
return metrics.reduce((sum, entry) => sum + entry.count, 0);
}

function findMarkdownFiles(dir) {
let results = [];
const entries = fs.readdirSync(dir, { withFileTypes: true });

for (const entry of entries) {
const fullPath = path.join(dir, entry.name);
if (entry.isDirectory()) {
results = results.concat(findMarkdownFiles(fullPath));
continue;
}

if (entry.isFile() && entry.name.endsWith('.md')) {
results.push(fullPath);
}
}

return results;
}

function updateMarkdownBadges(totalViews) {
const refreshDate = new Date().toISOString().split('T')[0];
const badgeRegex = /<!-- START BADGE -->[\s\S]*?<!-- END BADGE -->/g;
const badgeBlock = `<!-- START BADGE -->
<div align="center">
<img src="https://img.shields.io/badge/Total%20views-${totalViews}-limegreen" alt="Total views">
<p>Refresh Date: ${refreshDate}</p>
</div>
<!-- END BADGE -->`;

for (const file of findMarkdownFiles('.')) {
const content = fs.readFileSync(file, 'utf-8');
if (!badgeRegex.test(content)) {
continue;
}

const updated = content.replace(badgeRegex, badgeBlock);
fs.writeFileSync(file, updated);
console.log(`Updated badge in ${file}`);
}
}

(async () => {
try {
const fetched = await getLast14DaysTraffic();
const existing = readMetrics();
const merged = mergeMetrics(existing, fetched);
writeMetrics(merged);

const totalViews = calculateTotalViews(merged);
updateMarkdownBadges(totalViews);
} catch (error) {
console.error(error);
process.exit(1);
}
})();
71 changes: 39 additions & 32 deletions .github/workflows/use-visitor-counter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,36 +22,17 @@ jobs:
with:
fetch-depth: 0

- name: Shallow clone visitor counter logic
run: git clone --depth=1 https://github.com/brown9804/github-visitor-counter.git

- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: '20'

- name: Install dependencies for github-visitor-counter
run: |
cd github-visitor-counter
npm ci

- name: Run visitor counter logic (updates markdown badges and metrics.json)
run: node github-visitor-counter/update_repo_views_counter.js
run: node .github/scripts/update_repo_views_counter.js
env:
TRAFFIC_TOKEN: ${{ secrets.TRAFFIC_TOKEN }}
REPO: ${{ github.repository }}

- name: Move generated metrics.json to root
run: mv github-visitor-counter/metrics.json .

- name: List files for debugging
run: |
ls -l
ls -l github-visitor-counter

- name: Clean up visitor counter logic
run: rm -rf github-visitor-counter

- name: Configure Git author
run: |
git config --global user.name "github-actions[bot]"
Expand All @@ -63,24 +44,50 @@ jobs:
env:
TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
git fetch origin
git checkout ${{ github.head_ref }}
git pull origin ${{ github.head_ref }} || echo "No merge needed"
git add -A
git commit -m "Update visitor count" || echo "No changes to commit"
BRANCH="${{ github.head_ref }}"
git remote set-url origin https://x-access-token:${TOKEN}@github.com/${{ github.repository }}
git push origin HEAD:${{ github.head_ref }}
HAS_CHANGES=false
if ! git diff --quiet || ! git diff --cached --quiet || [ -n "$(git ls-files --others --exclude-standard)" ]; then
HAS_CHANGES=true
git stash push --include-untracked --message visitor-counter
fi
git fetch origin "$BRANCH"
git checkout -B "$BRANCH" "origin/$BRANCH"
if [ "$HAS_CHANGES" = true ]; then
git stash pop
fi
git add -A
if git diff --cached --quiet; then
echo "No changes to commit"
exit 0
fi
git commit -m "Update visitor count"
git pull --rebase origin "$BRANCH"
git push origin HEAD:"$BRANCH"

# Commit and push logic for non-PR events (merge, not rebase)
- name: Commit and push changes (non-PR)
if: github.event_name != 'pull_request'
env:
TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
git fetch origin
git checkout ${{ github.ref_name }} || git checkout -b ${{ github.ref_name }} origin/${{ github.ref_name }}
git pull origin ${{ github.ref_name }} || echo "No merge needed"
git add -A
git commit -m "Update visitor count" || echo "No changes to commit"
BRANCH="${{ github.ref_name }}"
git remote set-url origin https://x-access-token:${TOKEN}@github.com/${{ github.repository }}
git push origin HEAD:${{ github.ref_name }}
HAS_CHANGES=false
if ! git diff --quiet || ! git diff --cached --quiet || [ -n "$(git ls-files --others --exclude-standard)" ]; then
HAS_CHANGES=true
git stash push --include-untracked --message visitor-counter
fi
git fetch origin "$BRANCH"
git checkout -B "$BRANCH" "origin/$BRANCH"
if [ "$HAS_CHANGES" = true ]; then
git stash pop
fi
git add -A
if git diff --cached --quiet; then
echo "No changes to commit"
exit 0
fi
git commit -m "Update visitor count"
git pull --rebase origin "$BRANCH"
git push origin HEAD:"$BRANCH"
27 changes: 13 additions & 14 deletions 0_Azure/0_AzureFundamentals/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@ Costa Rica

[![License: GPL v3](https://img.shields.io/badge/License-GPLv3-blue.svg)](https://www.gnu.org/licenses/gpl-3.0)
[![GitHub](https://badgen.net/badge/icon/github?icon=github&label)](https://github.com)
[![GitHub](https://img.shields.io/badge/--181717?logo=github&logoColor=ffffff)](https://github.com/)
[brown9804](https://github.com/brown9804)
[![GitHub](https://img.shields.io/badge/--181717?logo=github&logoColor=ffffff)](https://github.com/) [Cloud2BR OSS - Learning Hub](https://github.com/Cloud2BR-MSFTLearningHub)

Last updated: 2026-01-29

Expand All @@ -21,44 +20,44 @@ Last updated: 2026-01-29

## Types of Cloud Services

![Alt text](https://github.com/brown9804/MSCloudEssentials_LPath/blob/main/0_Azure/img/AzureFundamentals/%5Bimg%5D_types_of_cloud_services.png)
![Alt text](https://github.com/Cloud2BR-MSFTLearningHub/DemosScenarios-TechTalks/blob/main/0_Azure/img/AzureFundamentals/%5Bimg%5D_types_of_cloud_services.png)

## Azure CLoud Models

![Alt text](https://github.com/brown9804/MSCloudEssentials_LPath/blob/main/0_Azure/img/AzureFundamentals/%5Bimg%5D_azure_cloud_models.png)
![Alt text](https://github.com/Cloud2BR-MSFTLearningHub/DemosScenarios-TechTalks/blob/main/0_Azure/img/AzureFundamentals/%5Bimg%5D_azure_cloud_models.png)

## Azure Security Rules

![Alt text](https://github.com/brown9804/MSCloudEssentials_LPath/blob/main/0_Azure/img/AzureFundamentals/%5Bimg%5D_azure_security_rules.png)
![Alt text](https://github.com/Cloud2BR-MSFTLearningHub/DemosScenarios-TechTalks/blob/main/0_Azure/img/AzureFundamentals/%5Bimg%5D_azure_security_rules.png)

## Azure Security Network

![Alt text](https://github.com/brown9804/MSCloudEssentials_LPath/blob/main/0_Azure/img/AzureFundamentals/%5Bimg%5D_azure_security_network.png)
![Alt text](https://github.com/Cloud2BR-MSFTLearningHub/DemosScenarios-TechTalks/blob/main/0_Azure/img/AzureFundamentals/%5Bimg%5D_azure_security_network.png)

## Azure DDoS Protection

![Alt text](https://github.com/brown9804/MSCloudEssentials_LPath/blob/main/0_Azure/img/AzureFundamentals/%5Bimg%5D_azure_network_DDos.png)
![Alt text](https://github.com/Cloud2BR-MSFTLearningHub/DemosScenarios-TechTalks/blob/main/0_Azure/img/AzureFundamentals/%5Bimg%5D_azure_network_DDos.png)

## Azure Firewall Rules

![Alt text](https://github.com/brown9804/MSCloudEssentials_LPath/blob/main/0_Azure/img/AzureFundamentals/%5Bimg%5D_azure_firewall_rules.png)
![Alt text](https://github.com/Cloud2BR-MSFTLearningHub/DemosScenarios-TechTalks/blob/main/0_Azure/img/AzureFundamentals/%5Bimg%5D_azure_firewall_rules.png)

![Alt text](https://github.com/brown9804/MSCloudEssentials_LPath/blob/main/0_Azure/img/AzureFundamentals/%5Bimg%5D_azure_firewall_rules_2.png)
![Alt text](https://github.com/Cloud2BR-MSFTLearningHub/DemosScenarios-TechTalks/blob/main/0_Azure/img/AzureFundamentals/%5Bimg%5D_azure_firewall_rules_2.png)

## Azure Security Features Identity

### 1. Authentication & Authorization
![Alt text](https://github.com/brown9804/MSCloudEssentials_LPath/blob/main/0_Azure/img/AzureFundamentals/%5Bimg%5D_azure_security_features_Identity_AuthenticationAuthorization.png)
![Alt text](https://github.com/Cloud2BR-MSFTLearningHub/DemosScenarios-TechTalks/blob/main/0_Azure/img/AzureFundamentals/%5Bimg%5D_azure_security_features_Identity_AuthenticationAuthorization.png)

### 2. Active Directory
![Alt text](https://github.com/brown9804/MSCloudEssentials_LPath/blob/main/0_Azure/img/AzureFundamentals/%5Bimg%5D_azure_security_features_AzureActiveDirectory.png)
![Alt text](https://github.com/Cloud2BR-MSFTLearningHub/DemosScenarios-TechTalks/blob/main/0_Azure/img/AzureFundamentals/%5Bimg%5D_azure_security_features_AzureActiveDirectory.png)

### 3. MFA
![Alt text](https://github.com/brown9804/MSCloudEssentials_LPath/blob/main/0_Azure/img/AzureFundamentals/%5Bimg%5D_azure_security_features-identity-MFA.png)
![Alt text](https://github.com/Cloud2BR-MSFTLearningHub/DemosScenarios-TechTalks/blob/main/0_Azure/img/AzureFundamentals/%5Bimg%5D_azure_security_features-identity-MFA.png)

<!-- START BADGE -->
<div align="center">
<img src="https://img.shields.io/badge/Total%20views-1535-limegreen" alt="Total views">
<p>Refresh Date: 2026-01-29</p>
<img src="https://img.shields.io/badge/Total%20views-1465-limegreen" alt="Total views">
<p>Refresh Date: 2026-04-07</p>
</div>
<!-- END BADGE -->
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@

Costa Rica

[![GitHub](https://img.shields.io/badge/--181717?logo=github&logoColor=ffffff)](https://github.com/)
[brown9804](https://github.com/brown9804)
[![GitHub](https://img.shields.io/badge/--181717?logo=github&logoColor=ffffff)](https://github.com/) [Cloud2BR OSS - Learning Hub](https://github.com/Cloud2BR-MSFTLearningHub)

Last updated: 2026-01-29

Expand Down Expand Up @@ -83,7 +82,7 @@ Last updated: 2026-01-29

<!-- START BADGE -->
<div align="center">
<img src="https://img.shields.io/badge/Total%20views-1535-limegreen" alt="Total views">
<p>Refresh Date: 2026-01-29</p>
<img src="https://img.shields.io/badge/Total%20views-1465-limegreen" alt="Total views">
<p>Refresh Date: 2026-04-07</p>
</div>
<!-- END BADGE -->
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@
Costa Rica

[![GitHub](https://badgen.net/badge/icon/github?icon=github&label)](https://github.com)
[![GitHub](https://img.shields.io/badge/--181717?logo=github&logoColor=ffffff)](https://github.com/)
[brown9804](https://github.com/brown9804)
[![GitHub](https://img.shields.io/badge/--181717?logo=github&logoColor=ffffff)](https://github.com/) [Cloud2BR OSS - Learning Hub](https://github.com/Cloud2BR-MSFTLearningHub)

Last updated: 2026-01-29

Expand Down Expand Up @@ -120,7 +119,7 @@ Testing and Automation:

<!-- START BADGE -->
<div align="center">
<img src="https://img.shields.io/badge/Total%20views-1535-limegreen" alt="Total views">
<p>Refresh Date: 2026-01-29</p>
<img src="https://img.shields.io/badge/Total%20views-1465-limegreen" alt="Total views">
<p>Refresh Date: 2026-04-07</p>
</div>
<!-- END BADGE -->
7 changes: 3 additions & 4 deletions 0_Azure/1_AzureData/0_DataStorage/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@

Costa Rica

[![GitHub](https://img.shields.io/badge/--181717?logo=github&logoColor=ffffff)](https://github.com/)
[brown9804](https://github.com/brown9804)
[![GitHub](https://img.shields.io/badge/--181717?logo=github&logoColor=ffffff)](https://github.com/) [Cloud2BR OSS - Learning Hub](https://github.com/Cloud2BR-MSFTLearningHub)

Last updated: 2026-01-29

Expand Down Expand Up @@ -50,7 +49,7 @@ graph TB

<!-- START BADGE -->
<div align="center">
<img src="https://img.shields.io/badge/Total%20views-1535-limegreen" alt="Total views">
<p>Refresh Date: 2026-01-29</p>
<img src="https://img.shields.io/badge/Total%20views-1465-limegreen" alt="Total views">
<p>Refresh Date: 2026-04-07</p>
</div>
<!-- END BADGE -->
9 changes: 4 additions & 5 deletions 0_Azure/1_AzureData/1_Databases/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@

Costa Rica

[![GitHub](https://img.shields.io/badge/--181717?logo=github&logoColor=ffffff)](https://github.com/)
[brown9804](https://github.com/brown9804)
[![GitHub](https://img.shields.io/badge/--181717?logo=github&logoColor=ffffff)](https://github.com/) [Cloud2BR OSS - Learning Hub](https://github.com/Cloud2BR-MSFTLearningHub)

Last updated: 2026-01-29

Expand All @@ -12,7 +11,7 @@ Last updated: 2026-01-29
> These functionalities include the ability to query data, manage relationships between different data items, enforce data integrity rules, and perform transactions. These products are typically used when you need to work with structured or unstructured data, and need more advanced features compared to basic data storage products.

<div align="center">
<img src="https://github.com/brown9804/MSCloudEssentials_LPath/assets/24630902/697f7265-647a-41e2-a2f5-ec4b66cf3321" alt="Centered Image" style="border: 2px solid #4CAF50; border-radius: 5px; padding: 5px;"/>
<img src="../../img/migrated-assets/azure-data-databases.png" alt="Centered Image" style="border: 2px solid #4CAF50; border-radius: 5px; padding: 5px;"/>
</div>


Expand Down Expand Up @@ -69,7 +68,7 @@ graph LR

<!-- START BADGE -->
<div align="center">
<img src="https://img.shields.io/badge/Total%20views-1535-limegreen" alt="Total views">
<p>Refresh Date: 2026-01-29</p>
<img src="https://img.shields.io/badge/Total%20views-1465-limegreen" alt="Total views">
<p>Refresh Date: 2026-04-07</p>
</div>
<!-- END BADGE -->
Loading
Loading