1
Fork 0
mirror of https://github.com/xivdev/EXDSchema.git synced 2025-06-04 07:07:45 +00:00
EXDSchema/.github/workflows/validate.yml
2025-03-24 21:12:33 -07:00

120 lines
4.1 KiB
YAML

name: Validate
run-name: "${{github.event.client_payload.pr_number && format('PR #{0} ({1})', github.event.client_payload.pr_number, github.event.client_payload.head_ref) || format('Push (@{0})', github.event.client_payload.actor)}}"
on:
repository_dispatch:
types: [version-pr, version-push]
permissions:
statuses: write
pull-requests: write
issues: write
discussions: write
contents: write
checks: write
concurrency:
group: ${{github.workflow}}-${{github.event.client_payload.head_ref}}
cancel-in-progress: true
jobs:
validate:
name: Validate
runs-on: ubuntu-latest
steps:
- name: Register Check
uses: myrotvorets/set-commit-status-action@v2.0.1
with:
context: Validate Schemas
sha: ${{github.event.client_payload.head_sha}}
status: pending
- name: Print Dispatch Info
run: |
echo "Actor: ${{github.event.client_payload.actor}}"
echo "PR Number: ${{github.event.client_payload.pr_number}}"
echo "Head Ref: ${{github.event.client_payload.head_ref}}"
echo "Head Sha: ${{github.event.client_payload.head_sha}}"
echo "Base Ref: ${{github.event.client_payload.base_ref}}"
- name: Checkout Head (${{github.event.client_payload.head_ref}})
uses: actions/checkout@v4
with:
ref: ${{github.event.client_payload.head_sha}}
persist-credentials: false
path: pr
- name: Checkout Base (${{github.event.client_payload.base_ref}})
uses: actions/checkout@v4
with:
ref: ${{github.event.client_payload.base_ref}}
persist-credentials: false
path: base
- name: Download EXDTools
uses: robinraju/release-downloader@v1
with:
repository: xivdev/EXDTools
fileName: 'EXDTooler'
latest: true
- name: Chmod Executable
run: chmod +x EXDTooler
- name: Run Validation
id: validation
run: |
./EXDTooler --gha --debug --verbose validate -c base/.github/columns.yml -s pr -b base
- name: Write out summary
if: always()
run: |
echo "${{steps.validation.outputs.summary}}" > summary.txt
cat summary.txt >> $GITHUB_STEP_SUMMARY
- uses: myrotvorets/set-commit-status-action@v2.0.1
if: always()
with:
sha: ${{github.event.client_payload.head_sha}}
context: Validate Schemas
status: ${{job.status}}
- name: Wipe previous comments (PR)
if: always() && github.event.action == 'version-pr'
uses: actions/github-script@v7
with:
script: |
const comments = (await github.rest.issues.listComments({
issue_number: context.payload.client_payload.pr_number,
owner: context.repo.owner,
repo: context.repo.repo
})).data
const comment = comments.filter(comment => comment.user.login === 'github-actions[bot]');
if (comment.length > 0) {
for (const c of comment) {
await github.graphql(`
mutation MinimizeComment($classifier: ReportedContentClassifiers!, $id: ID!) {
minimizeComment(input:{classifier: $classifier, subjectId: $id}) {
minimizedComment {
isMinimized
viewerCanMinimize
}
}
}
`, { classifier: 'OUTDATED', id: c.node_id });
}
}
- name: Post Validation Results (PR)
if: always() && github.event.action == 'version-pr'
uses: actions/github-script@v7
with:
script: |
const summary = require('fs').readFileSync('summary.txt', 'utf-8');
github.rest.issues.createComment({
issue_number: context.payload.client_payload.pr_number,
owner: context.repo.owner,
repo: context.repo.repo,
body: summary
});