Skip to content

Commit 72feebb

Browse files
authored
refactor(workflow): auto update halted days counter
1 parent 2f5c572 commit 72feebb

File tree

1 file changed

+21
-13
lines changed

1 file changed

+21
-13
lines changed

.github/workflows/update-readme.yml

Lines changed: 21 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name: Update README - Development Suspended Counter
22

33
on:
44
schedule:
5-
- cron: '0 0 * * *'
5+
- cron: '29 10 * * *'
66
workflow_dispatch:
77

88
permissions:
@@ -13,31 +13,39 @@ jobs:
1313
runs-on: ubuntu-latest
1414

1515
steps:
16-
- name: Checkout repository
16+
- name: Checkout Repository
1717
uses: actions/checkout@v3
18+
with:
19+
fetch-depth: 0
1820

19-
- name: Calculate halted days and update README
21+
- name: Calculate Elapsed Days and Update README
2022
run: |
21-
# Set the date when development was suspended (YYYY-MM-DD)
22-
HALT_DATE="2025-03-13" # Adjust this date as needed
23-
CURRENT_DATE=$(date +%Y-%m-%d)
24-
# Calculate the difference in days
25-
DAYS=$(( ( $(date -d "$CURRENT_DATE" +%s) - $(date -d "$HALT_DATE" +%s) )/(60*60*24) ))
26-
echo "Calculated halted days: $DAYS"
23+
# Determine if external commits are present
24+
LAST_WORKFLOW_COMMIT=$(git log --grep="docs(update-readme): update README" -n 1 --format=%H)
25+
CURRENT_COMMIT=$(git rev-parse HEAD)
26+
27+
if [ "$CURRENT_COMMIT" != "$LAST_WORKFLOW_COMMIT" ]; then
28+
DAYS=0
29+
echo "External commits detected. Setting elapsed days to 0."
30+
else
31+
HALT_DATE="2025-03-19"
32+
CURRENT_DATE=$(date +%Y-%m-%d)
33+
DAYS=$(( ( $(date -d "$CURRENT_DATE" +%s) - $(date -d "$HALT_DATE" +%s) )/(60*60*24) ))
34+
echo "Calculated elapsed days: $DAYS"
35+
fi
2736
28-
# Replace the marker text in README.md with the updated counter
2937
sed -i "s/<!--HALTED-DAYS-->.*<!--HALTED-DAYS-->/<!--HALTED-DAYS-->🔮 Project Status: Development Temporarily Suspended – $DAYS Days Elapsed<!--HALTED-DAYS-->/" README.md
3038
echo "Updated README.md content:"
3139
cat README.md
3240
33-
- name: Commit and push changes
41+
- name: Commit and Push Changes
3442
run: |
3543
git config user.name "rhythmusbyte"
3644
git config user.email "akhilmahesh@proton.me"
3745
git add README.md
3846
if [ -n "$(git status --porcelain)" ]; then
3947
git commit -m "docs(update-readme): update README with $DAYS days elapsed"
40-
git push
48+
git push --force
4149
else
4250
echo "No changes detected."
43-
fi
51+
fi

0 commit comments

Comments
 (0)