Skip to content

Commit 9831cd3

Browse files
authored
Merge pull request #5 from MicrosoftCloudEssentials-LearningHub/adjusting-pipelines-visitscounter
clean
2 parents 6a3edd0 + 3a59179 commit 9831cd3

File tree

4 files changed

+39
-42
lines changed

4 files changed

+39
-42
lines changed

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

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ jobs:
1818
uses: actions/checkout@v4
1919
with:
2020
fetch-depth: 0
21+
ref: ${{ github.head_ref || github.ref_name }}
2122

2223
- name: Set up Python
2324
uses: actions/setup-python@v4
@@ -35,13 +36,23 @@ jobs:
3536
- name: Update last modified date in Markdown files
3637
run: python .github/workflows/update_date.py
3738

38-
- name: Commit changes
39+
- name: Commit and merge changes
3940
env:
40-
TOKEN: ${{ secrets.GITHUB_TOKEN }}
41+
PR_BRANCH: ${{ github.head_ref || github.ref_name }}
42+
GIT_AUTHOR_NAME: github-actions[bot]
43+
GIT_AUTHOR_EMAIL: github-actions[bot]@users.noreply.github.com
44+
GIT_COMMITTER_NAME: github-actions[bot]
45+
GIT_COMMITTER_EMAIL: github-actions[bot]@users.noreply.github.com
4146
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"
47+
# Ensure we're on the correct branch
48+
git switch -c "$PR_BRANCH" || git switch "$PR_BRANCH"
49+
50+
# Stage and commit changes if any
4451
git add -A
45-
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 }}
47-
git push origin HEAD:${{ github.event.pull_request.head.ref }}
52+
git diff --staged --quiet || git commit -m "Update last modified date in Markdown files"
53+
54+
# Pull and merge existing changes
55+
git pull origin "$PR_BRANCH" --no-rebase
56+
57+
# Push all changes
58+
git push origin "$PR_BRANCH"

.github/workflows/use-visitor-counter.yml

Lines changed: 19 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ jobs:
2121
uses: actions/checkout@v4
2222
with:
2323
fetch-depth: 0
24+
ref: ${{ github.head_ref || github.ref_name }}
2425

2526
- name: Shallow clone visitor counter logic
2627
run: git clone --depth=1 https://github.com/brown9804/github-visitor-counter.git
@@ -57,38 +58,23 @@ jobs:
5758
git config --global user.name "github-actions[bot]"
5859
git config --global user.email "github-actions[bot]@users.noreply.github.com"
5960
60-
- name: Commit and push changes (PR)
61-
if: github.event_name == 'pull_request'
61+
- name: Commit and merge changes
6262
env:
63-
TOKEN: ${{ secrets.GITHUB_TOKEN }}
63+
PR_BRANCH: ${{ github.head_ref || github.ref_name }}
64+
GIT_AUTHOR_NAME: github-actions[bot]
65+
GIT_AUTHOR_EMAIL: github-actions[bot]@users.noreply.github.com
66+
GIT_COMMITTER_NAME: github-actions[bot]
67+
GIT_COMMITTER_EMAIL: github-actions[bot]@users.noreply.github.com
6468
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
69+
# Ensure we're on the correct branch
70+
git switch -c "$PR_BRANCH" || git switch "$PR_BRANCH"
71+
72+
# Stage and commit changes if any
73+
git add -A
74+
git diff --staged --quiet || git commit -m "Update visitor count"
75+
76+
# Pull and merge existing changes
77+
git pull origin "$PR_BRANCH" --no-rebase
78+
79+
# Push all changes
80+
git push origin "$PR_BRANCH"

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -447,7 +447,7 @@ Last updated: 2025-07-21
447447

448448
<!-- START BADGE -->
449449
<div align="center">
450-
<img src="https://img.shields.io/badge/Total%20views-164-limegreen" alt="Total views">
450+
<img src="https://img.shields.io/badge/Total%20views-180-limegreen" alt="Total views">
451451
<p>Refresh Date: 2025-07-21</p>
452452
</div>
453453
<!-- END BADGE -->

terraform-infrastructure/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ graph TD;
109109

110110
<!-- START BADGE -->
111111
<div align="center">
112-
<img src="https://img.shields.io/badge/Total%20views-164-limegreen" alt="Total views">
112+
<img src="https://img.shields.io/badge/Total%20views-180-limegreen" alt="Total views">
113113
<p>Refresh Date: 2025-07-21</p>
114114
</div>
115115
<!-- END BADGE -->

0 commit comments

Comments
 (0)