Skip to content

Commit 8f01707

Browse files
Add visual indicator for nonce value and last update timestamp (#8)
* Initial plan * Add visual indicator for nonce value and timestamp Co-authored-by: hesreallyhim <172150522+hesreallyhim@users.noreply.github.com> * Simplify workflow: reuse NONCE_PATTERN variable and improve readability Co-authored-by: hesreallyhim <172150522+hesreallyhim@users.noreply.github.com> * Add comments explaining matching invariants for nonce and timestamp patterns Co-authored-by: hesreallyhim <172150522+hesreallyhim@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: hesreallyhim <172150522+hesreallyhim@users.noreply.github.com>
1 parent 34bfa22 commit 8f01707

2 files changed

Lines changed: 18 additions & 1 deletion

File tree

.github/workflows/update-nonce.yml

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,13 +39,28 @@ jobs:
3939
NEW_NONCE=$(printf "%06d" $((RANDOM % 1000000)))
4040
echo "Generated new nonce: $NEW_NONCE"
4141
42+
# Get current timestamp in UTC
43+
TIMESTAMP=$(date -u +"%Y-%m-%d %H:%M:%S UTC")
44+
echo "Current timestamp: $TIMESTAMP"
45+
4246
# Find and replace nonce=NNNNNN pattern with new nonce
4347
# Only within the NONCE section markers
48+
# MATCHING INVARIANT FOR NONCE: Must be exactly "nonce=" followed by
49+
# exactly 6 digits (e.g., nonce=019757). You can change text/styling
50+
# around it, but the pattern "nonce=[0-9]{6}" must remain intact.
4451
NONCE_PATTERN='/<!-- NONCE -->/,/<!-- NONCE-END -->/'
4552
NONCE_REPLACEMENT='s/nonce=[0-9]\{6\}/nonce='"$NEW_NONCE"'/g'
4653
sed -i "${NONCE_PATTERN}${NONCE_REPLACEMENT}" README.md
4754
48-
echo "Updated README.md with new nonce value"
55+
# Update the timestamp in the visual indicator
56+
# MATCHING INVARIANT FOR TIMESTAMP: Must be exactly "Last updated: `"
57+
# followed by any characters, followed by "`" (backtick).
58+
# The text between backticks can be any format, but the pattern
59+
# "Last updated: `...`" must remain intact (including backticks).
60+
TS_REPL='s/Last updated: `[^`]*`/Last updated: `'"$TIMESTAMP"'`/g'
61+
sed -i "${NONCE_PATTERN}${TS_REPL}" README.md
62+
63+
echo "Updated README.md with new nonce value and timestamp"
4964
5065
- name: Commit and push changes
5166
if: steps.check-nonce.outputs.contains_nonce == 'true'

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ GitHub uses a service called [camo](https://docs.github.com/en/authentication/ke
3939

4040

4141
[![test-github-cache-bust](https://github-readme-stats-plus-theta.vercel.app/api/pin?username=hesreallyhim&repo=test-github-cache-bust&show_issues=true&nonce=019757)](https://github.com/hesreallyhim)
42+
43+
**Cache-busting status:** `nonce=019757` | Last updated: `2025-11-06 16:25:48 UTC`
4244
<!-- NONCE-END -->
4345

4446

0 commit comments

Comments
 (0)