Skip to content

Commit f28701b

Browse files
authored
Create daily-commit-link-tracker.yml
1 parent 061db9b commit f28701b

File tree

1 file changed

+41
-0
lines changed

1 file changed

+41
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
name: Daily Commit Link Tracker
2+
3+
on:
4+
push:
5+
branches:
6+
- main # or your default branch name
7+
workflow_dispatch:
8+
9+
jobs:
10+
update-link:
11+
runs-on: ubuntu-latest
12+
13+
steps:
14+
- uses: actions/checkout@v2
15+
16+
- name: Get Current Commit Link
17+
id: commit-link
18+
run: |
19+
echo "Commit URL: https://github.com/${{ github.repository }}/commit/${{ github.sha }}"
20+
echo "Commit URL: https://github.com/${{ github.repository }}/commit/${{ github.sha }}" > commit-link.txt
21+
22+
- name: Update README with the Latest Commit
23+
run: |
24+
COMMIT_LINK=$(cat commit-link.txt)
25+
sed -i "s|<!--START_SECTION:latest-commit-->.*<!--END_SECTION:latest-commit-->|<!--START_SECTION:latest-commit-->$COMMIT_LINK<!--END_SECTION:latest-commit-->|" README.md
26+
27+
- name: Add Today's Solution Badge
28+
run: |
29+
# Example badge URL: Customize it for the actual solution
30+
BADGE_URL="https://img.shields.io/badge/GeeksforGeeks-Solution%20of%20the%20Day-blue"
31+
BADGE_LINK="[![Today's POTD Solution]($BADGE_URL)](https://github.com/Hunterdii/GeeksforGeeks-POTD)"
32+
# Add the badge link to the README
33+
sed -i "s|<!--START_SECTION:potd-badge-->.*<!--END_SECTION:potd-badge-->|<!--START_SECTION:potd-badge-->$BADGE_LINK<!--END_SECTION:potd-badge-->|" README.md
34+
35+
- name: Commit and Push Changes
36+
run: |
37+
git config --local user.email "github-actions[bot]@users.noreply.github.com"
38+
git config --local user.name "github-actions[bot]"
39+
git add README.md
40+
git diff-index --quiet HEAD || git commit -m "Update commit link and POTD badge"
41+
git push

0 commit comments

Comments
 (0)