Skip to content

Commit 99b855d

Browse files
committed
Merge branch 'base-challenge-template' of github.com:scaffold-eth/se-2-challenges into challenge-stablecoins
2 parents 2054825 + 2be061b commit 99b855d

File tree

2 files changed

+143
-0
lines changed

2 files changed

+143
-0
lines changed

.github/Revalidation.md

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
# GitHub Actions Setup
2+
3+
## README Revalidation Workflow
4+
5+
This repository includes a GitHub Action that automatically revalidates challenge README files on speedrunethereum.com whenever they are updated.
6+
7+
### How it works
8+
9+
The workflow (`revalidate-challenge-readme.yml`) triggers when:
10+
11+
1. **Push events** that modify README files on challenge branches
12+
2. **Merged pull requests** that modify README files targeting challenge branches
13+
14+
**Watched files:**
15+
16+
- `README.md` (root level challenge description)
17+
- `extension/README.md.args.mjs` (template file)
18+
19+
**Supported branches:**
20+
21+
- Any branch matching the pattern `challenge-*` (e.g., `challenge-tokenization`, `challenge-decentralized-staking`)
22+
23+
### Setup Requirements
24+
25+
To use this workflow, you need to configure the following repository secret:
26+
27+
#### Required Secret
28+
29+
**`REVALIDATION_TOKEN`**
30+
31+
- Description: Authentication token for speedrunethereum.com API
32+
- Required for: Making revalidation API calls
33+
- Setup: Go to your repository Settings → Secrets and variables → Actions → Repository secrets
34+
35+
### How the workflow extracts challenge names
36+
37+
The workflow automatically extracts the challenge name from the branch name:
38+
39+
- `challenge-tokenization``tokenization`
40+
- `challenge-decentralized-staking``decentralized-staking`
41+
- `challenge-dex``dex`
42+
43+
This extracted name is used to construct the revalidation URL:
44+
45+
```
46+
https://speedrunethereum.com/api/revalidate?token=${REVALIDATION_TOKEN}&path=/challenge/${challenge_name}
47+
```
48+
49+
### Workflow Features
50+
51+
-**Automatic triggering** on README changes
52+
-**Branch pattern matching** for challenge branches only
53+
-**Smart challenge name extraction** from branch names
54+
-**Error handling** with proper HTTP status checking
55+
-**Detailed logging** of revalidation attempts
56+
-**GitHub Actions summary** with status and details
57+
-**Support for both direct pushes and merged PRs**
58+
59+
### Troubleshooting
60+
61+
If the workflow fails:
62+
63+
1. **Check the secret**: Ensure `REVALIDATION_TOKEN` is correctly set
64+
2. **Verify branch name**: Make sure you're on a `challenge-*` branch
65+
3. **Check file paths**: Ensure you're modifying `README.md` or `extension/README.md.args.mjs`
66+
4. **Review logs**: Check the GitHub Actions logs for detailed error messages
67+
68+
### Testing the workflow
69+
70+
You can test the workflow by:
71+
72+
1. Making a small change to `README.md` on a challenge branch
73+
2. Committing and pushing the change
74+
3. Checking the Actions tab in your GitHub repository
75+
4. Reviewing the workflow run and summary for success/failure status
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
name: Revalidate Challenge README
2+
3+
on:
4+
push:
5+
paths:
6+
- "README.md"
7+
branches:
8+
- "challenge-*"
9+
10+
jobs:
11+
revalidate:
12+
runs-on: ubuntu-latest
13+
if: github.event_name == 'push' || (github.event_name == 'pull_request' && github.event.pull_request.merged == true)
14+
15+
steps:
16+
- name: Extract challenge name from branch
17+
id: extract_challenge
18+
run: |
19+
# Get the branch name
20+
if [ "${{ github.event_name }}" = "pull_request" ]; then
21+
BRANCH_NAME="${{ github.event.pull_request.base.ref }}"
22+
else
23+
BRANCH_NAME="${{ github.ref_name }}"
24+
fi
25+
26+
# Extract challenge name from branch (e.g., challenge-tokenization -> tokenization)
27+
if [[ $BRANCH_NAME =~ ^challenge-(.+)$ ]]; then
28+
CHALLENGE_NAME="${BASH_REMATCH[1]}"
29+
echo "challenge_name=$CHALLENGE_NAME" >> $GITHUB_OUTPUT
30+
else
31+
echo "❌ Branch name does not match challenge pattern: $BRANCH_NAME"
32+
exit 1
33+
fi
34+
35+
- name: Revalidate speedrunethereum.com
36+
if: steps.extract_challenge.outputs.challenge_name != ''
37+
run: |
38+
CHALLENGE_NAME="${{ steps.extract_challenge.outputs.challenge_name }}"
39+
40+
RESPONSE=$(curl -s -w "\n%{http_code}" -X POST \
41+
"https://speedrunethereum.com/api/revalidate?token=${{ secrets.REVALIDATION_TOKEN }}&path=/challenge/$CHALLENGE_NAME" \
42+
-H "Content-Type: application/json")
43+
44+
HTTP_CODE=$(echo "$RESPONSE" | tail -n1)
45+
46+
if [ "$HTTP_CODE" -eq 200 ]; then
47+
echo "✅ Successfully revalidated challenge $CHALLENGE_NAME"
48+
else
49+
RESPONSE_BODY=$(echo "$RESPONSE" | head -n -1)
50+
echo "❌ Failed to revalidate challenge $CHALLENGE_NAME (HTTP $HTTP_CODE)"
51+
echo "Response: $RESPONSE_BODY"
52+
exit 1
53+
fi
54+
55+
- name: Add summary
56+
if: always()
57+
run: |
58+
echo "## 📄 README Revalidation" >> $GITHUB_STEP_SUMMARY
59+
if [ "${{ steps.extract_challenge.outputs.challenge_name }}" != "" ]; then
60+
echo "**Challenge:** \`${{ steps.extract_challenge.outputs.challenge_name }}\`" >> $GITHUB_STEP_SUMMARY
61+
if [ "${{ job.status }}" = "success" ]; then
62+
echo "✅ Successfully revalidated" >> $GITHUB_STEP_SUMMARY
63+
else
64+
echo "❌ Failed to revalidate" >> $GITHUB_STEP_SUMMARY
65+
fi
66+
else
67+
echo "❌ Could not extract challenge name from branch" >> $GITHUB_STEP_SUMMARY
68+
fi

0 commit comments

Comments
 (0)