Adding workflow to ensure that the readme is correctly updated
This commit is contained in:
parent
f7f6ac7d3d
commit
02909a6f8b
75
.github/workflows/validate-readme.yml
vendored
Normal file
75
.github/workflows/validate-readme.yml
vendored
Normal file
@ -0,0 +1,75 @@
|
||||
name: Validate README.md
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
types: [opened, synchronize, reopened]
|
||||
paths:
|
||||
- "instructions/**"
|
||||
- "prompts/**"
|
||||
- "chatmodes/**"
|
||||
- "*.js"
|
||||
|
||||
jobs:
|
||||
validate-readme:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Setup Node.js
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: "20"
|
||||
|
||||
- name: Update README.md
|
||||
run: node update-readme.js
|
||||
|
||||
- name: Check for README.md changes
|
||||
id: check-diff
|
||||
run: |
|
||||
if git diff --exit-code README.md; then
|
||||
echo "No changes to README.md after running update script."
|
||||
echo "status=success" >> $GITHUB_OUTPUT
|
||||
else
|
||||
echo "Changes detected in README.md after running update script."
|
||||
echo "status=failure" >> $GITHUB_OUTPUT
|
||||
echo "diff<<EOF" >> $GITHUB_OUTPUT
|
||||
git diff README.md >> $GITHUB_OUTPUT
|
||||
echo "EOF" >> $GITHUB_OUTPUT
|
||||
fi
|
||||
|
||||
- name: Comment on PR if README.md needs updating
|
||||
if: steps.check-diff.outputs.status == 'failure'
|
||||
uses: actions/github-script@v7
|
||||
with:
|
||||
github-token: ${{ secrets.GITHUB_TOKEN }}
|
||||
script: |
|
||||
const diff = `${{ steps.check-diff.outputs.diff }}`;
|
||||
const body = `## ⚠️ README.md needs to be updated
|
||||
|
||||
The \`update-readme.js\` script detected changes that need to be made to the README.md file.
|
||||
|
||||
Please run \`node update-readme.js\` locally and commit the changes before merging this PR.
|
||||
|
||||
<details>
|
||||
<summary>View diff</summary>
|
||||
|
||||
\`\`\`diff
|
||||
${diff}
|
||||
\`\`\`
|
||||
</details>`;
|
||||
|
||||
github.rest.issues.createComment({
|
||||
owner: context.repo.owner,
|
||||
repo: context.repo.repo,
|
||||
issue_number: context.issue.number,
|
||||
body: body
|
||||
});
|
||||
|
||||
- name: Fail workflow if README.md needs updating
|
||||
if: steps.check-diff.outputs.status == 'failure'
|
||||
run: |
|
||||
echo "❌ README.md needs to be updated. Please run 'node update-readme.js' locally and commit the changes."
|
||||
exit 1
|
||||
@ -61,6 +61,8 @@ Your goal is to...
|
||||
2. **Create a new branch** for your contribution
|
||||
3. **Add your instruction or prompt file** following the guidelines above
|
||||
4. **Run the update script** (optional): `node update-readme.js` to update the README with your new file
|
||||
- A GitHub Actions workflow will verify that this step was performed correctly
|
||||
- If the README.md would be modified by running the script, the PR check will fail with a comment showing the required changes
|
||||
5. **Submit a pull request** with:
|
||||
- A clear title describing your contribution
|
||||
- A brief description of what your instruction/prompt does
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user