awesome-copilot/.github/workflows/validate-metadata.yml
2025-07-17 15:41:14 +09:00

80 lines
2.6 KiB
YAML

name: Validate metadata.json
on:
pull_request:
types: [opened, synchronize, reopened]
paths:
- "instructions/**"
- "prompts/**"
- "chatmodes/**"
- "*.js"
jobs:
validate-metadata:
permissions:
pull-requests: write
contents: read
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 metadata.json
run: node update-metadata.js
- name: Check for metadata.json changes
id: check-diff
run: |
if git diff --exit-code metadata.json; then
echo "No changes to metadata.json after running update script."
echo "status=success" >> $GITHUB_OUTPUT
else
echo "Changes detected in metadata.json after running update script."
echo "status=failure" >> $GITHUB_OUTPUT
echo "diff<<EOF" >> $GITHUB_OUTPUT
git diff metadata.json >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT
fi
- name: Output diff to logs for non-write users
if: steps.check-diff.outputs.status == 'failure' && github.event.pull_request.head.repo.permissions.push != true
run: |
echo "::group::metadata.json diff (changes needed)"
echo "The following changes need to be made to metadata.json:"
echo ""
git diff metadata.json
echo "::endgroup::"
- name: Comment on PR if metadata.json needs updating
if: steps.check-diff.outputs.status == 'failure' && github.event.pull_request.head.repo.permissions.push == true
uses: marocchino/sticky-pull-request-comment@v2
with:
header: metadata-validation
message: |
## ⚠️ `metadata.json` needs to be updated
The `update-metadata.js` script detected changes that need to be made to the `metadata.json` file.
Please run `node update-metadata.js` locally and commit the changes before merging this PR.
<details>
<summary>View diff</summary>
```diff
${{ steps.check-diff.outputs.diff }}
```
</details>
- name: Fail workflow if metadata.json needs updating
if: steps.check-diff.outputs.status == 'failure'
run: |
echo "❌ `metadata.json` needs to be updated. Please run 'node update-metadata.js' locally and commit the changes."
exit 1