Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Nov 6, 2025

Closes: #[issue_number]

Implements automated cache-busting for README images via GitHub Action that triggers on issue open events containing "nonce" keyword.

Implementation

  • Workflow trigger: Issues with "nonce" in body (case-insensitive)
  • Pattern matching: Targets nonce=NNNNNN (6 digits) within <!-- NONCE --> section markers only
  • Replacement logic: Generates pseudo-random 6-digit value via printf "%06d" $((RANDOM % 1000000)), replaces all matches globally with same value
  • Security: Issue body passed through environment variables to prevent command injection; explicit GITHUB_TOKEN permissions (contents: write, issues: read)

Example

When an issue containing "nonce" is opened, both URLs in the NONCE section update atomically:

<!-- NONCE -->
[![card](https://example.com/api/pin?nonce=123456)](...)
[![card](https://example.com/api/pin?nonce=123456)](...)
<!-- NONCE-END -->

<!-- NONCE -->
[![card](https://example.com/api/pin?nonce=047829)](...)
[![card](https://example.com/api/pin?nonce=047829)](...)
<!-- NONCE-END -->

The BASELINE section (without nonce parameter) remains unchanged.

Original prompt

create a GitHub Action that is triggered when an Issue is open - if the Issue body contains the word "nonce", then it should continue, else stop - if it continues it should scan the body of the README.md for the section delimited by HTML comments NONCE and NONCE-END - within that body it should apply pattern matching to identify any text of the form "nonce=NNNNNN" ("nonce", followed by "=", followed by 6 digits) - it should generate a pseudo-random 6-digit numeral - and then replace the value of NNNNNN with that numeral (same numeral globally in the readme, i.e., if the pattern matches more than once, the value should be the same


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI and others added 3 commits November 6, 2025 15:29
Co-authored-by: hesreallyhim <172150522+hesreallyhim@users.noreply.github.com>
Co-authored-by: hesreallyhim <172150522+hesreallyhim@users.noreply.github.com>
Co-authored-by: hesreallyhim <172150522+hesreallyhim@users.noreply.github.com>
Copilot AI changed the title [WIP] Add GitHub Action for nonce replacement in README Add GitHub Action to update nonce query parameter on issue trigger Nov 6, 2025
Copilot AI requested a review from hesreallyhim November 6, 2025 15:40
@hesreallyhim hesreallyhim marked this pull request as ready for review November 6, 2025 15:57
@hesreallyhim
Copy link
Owner

@copilot is it posssible to throttle the action so that it will not return if an existing run of that same workflow is in progress? we should also have a visual indicator that shows the timestamp that the nonce was last changed.

@hesreallyhim hesreallyhim merged commit 7004c40 into main Nov 6, 2025
1 check failed
@hesreallyhim hesreallyhim deleted the copilot/add-nonce-replacement-action branch November 16, 2025 02:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants