Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
61 changes: 61 additions & 0 deletions .github/workflows/update-nonce.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
---
name: Update Nonce on Issue Open

'on':
issues:
types: [opened]

jobs:
update-nonce:
runs-on: ubuntu-latest
permissions:
contents: write
issues: read

steps:
- name: Check if issue body contains "nonce"
id: check-nonce
env:
ISSUE_BODY: ${{ github.event.issue.body }}
run: |
if echo "$ISSUE_BODY" | grep -qi "nonce"; then
echo "contains_nonce=true" >> $GITHUB_OUTPUT
echo "Issue body contains 'nonce' - proceeding"
else
echo "contains_nonce=false" >> $GITHUB_OUTPUT
echo "Issue body does not contain 'nonce' - stopping"
fi

- name: Checkout repository
if: steps.check-nonce.outputs.contains_nonce == 'true'
uses: actions/checkout@v4
with:
token: ${{ secrets.GITHUB_TOKEN }}

- name: Update nonce in README
if: steps.check-nonce.outputs.contains_nonce == 'true'
run: |
# Generate a random 6-digit number
NEW_NONCE=$(printf "%06d" $((RANDOM % 1000000)))
echo "Generated new nonce: $NEW_NONCE"

# Find and replace nonce=NNNNNN pattern with new nonce
# Only within the NONCE section markers
NONCE_PATTERN='/<!-- NONCE -->/,/<!-- NONCE-END -->/'
NONCE_REPLACEMENT='s/nonce=[0-9]\{6\}/nonce='"$NEW_NONCE"'/g'
sed -i "${NONCE_PATTERN}${NONCE_REPLACEMENT}" README.md

echo "Updated README.md with new nonce value"

- name: Commit and push changes
if: steps.check-nonce.outputs.contains_nonce == 'true'
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git add README.md
if git diff --staged --quiet; then
echo "No changes to commit"
else
git commit -m "Update nonce value in README [skip ci]"
git push
fi
Loading