Skip to content

Commit 688cc97

Browse files
authored
Merge pull request #19 from github/readme-workflow
Adding workflow to ensure that the readme is correctly updated
2 parents f7f6ac7 + 02909a6 commit 688cc97

File tree

2 files changed

+77
-0
lines changed

2 files changed

+77
-0
lines changed
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
name: Validate README.md
2+
3+
on:
4+
pull_request:
5+
types: [opened, synchronize, reopened]
6+
paths:
7+
- "instructions/**"
8+
- "prompts/**"
9+
- "chatmodes/**"
10+
- "*.js"
11+
12+
jobs:
13+
validate-readme:
14+
runs-on: ubuntu-latest
15+
steps:
16+
- name: Checkout code
17+
uses: actions/checkout@v4
18+
with:
19+
fetch-depth: 0
20+
21+
- name: Setup Node.js
22+
uses: actions/setup-node@v4
23+
with:
24+
node-version: "20"
25+
26+
- name: Update README.md
27+
run: node update-readme.js
28+
29+
- name: Check for README.md changes
30+
id: check-diff
31+
run: |
32+
if git diff --exit-code README.md; then
33+
echo "No changes to README.md after running update script."
34+
echo "status=success" >> $GITHUB_OUTPUT
35+
else
36+
echo "Changes detected in README.md after running update script."
37+
echo "status=failure" >> $GITHUB_OUTPUT
38+
echo "diff<<EOF" >> $GITHUB_OUTPUT
39+
git diff README.md >> $GITHUB_OUTPUT
40+
echo "EOF" >> $GITHUB_OUTPUT
41+
fi
42+
43+
- name: Comment on PR if README.md needs updating
44+
if: steps.check-diff.outputs.status == 'failure'
45+
uses: actions/github-script@v7
46+
with:
47+
github-token: ${{ secrets.GITHUB_TOKEN }}
48+
script: |
49+
const diff = `${{ steps.check-diff.outputs.diff }}`;
50+
const body = `## ⚠️ README.md needs to be updated
51+
52+
The \`update-readme.js\` script detected changes that need to be made to the README.md file.
53+
54+
Please run \`node update-readme.js\` locally and commit the changes before merging this PR.
55+
56+
<details>
57+
<summary>View diff</summary>
58+
59+
\`\`\`diff
60+
${diff}
61+
\`\`\`
62+
</details>`;
63+
64+
github.rest.issues.createComment({
65+
owner: context.repo.owner,
66+
repo: context.repo.repo,
67+
issue_number: context.issue.number,
68+
body: body
69+
});
70+
71+
- name: Fail workflow if README.md needs updating
72+
if: steps.check-diff.outputs.status == 'failure'
73+
run: |
74+
echo "❌ README.md needs to be updated. Please run 'node update-readme.js' locally and commit the changes."
75+
exit 1

CONTRIBUTING.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,8 @@ Your goal is to...
6161
2. **Create a new branch** for your contribution
6262
3. **Add your instruction or prompt file** following the guidelines above
6363
4. **Run the update script** (optional): `node update-readme.js` to update the README with your new file
64+
- A GitHub Actions workflow will verify that this step was performed correctly
65+
- If the README.md would be modified by running the script, the PR check will fail with a comment showing the required changes
6466
5. **Submit a pull request** with:
6567
- A clear title describing your contribution
6668
- A brief description of what your instruction/prompt does

0 commit comments

Comments
 (0)