Skip to content

Commit 735d283

Browse files
[Misc] add annotation for pre-commit failure (#573)
1 parent 3307c5b commit 735d283

1 file changed

Lines changed: 14 additions & 0 deletions

File tree

.github/workflows/pr-validation.yml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,22 @@ jobs:
6161
run: pip install pre-commit
6262

6363
- name: Run pre-commit
64+
id: pre-commit
6465
run: pre-commit run --all-files --show-diff-on-failure
6566

67+
- name: Post failure comment on PR
68+
if: failure() && steps.pre-commit.outcome == 'failure'
69+
uses: actions/github-script@v7
70+
with:
71+
script: |
72+
const body = `⚠️ **Pre-commit checks failed**\n\nPlease run the following locally and commit the fixes:\n\`\`\`bash\npre-commit run --all-files\ngit add -u && git commit\n\`\`\`\nSee [CONTRIBUTING.md](../blob/main/CONTRIBUTING.md#pre-commit-check) for setup instructions.`;
73+
await github.rest.issues.createComment({
74+
owner: context.repo.owner,
75+
repo: context.repo.repo,
76+
issue_number: context.issue.number,
77+
body: body
78+
});
79+
6680
test-and-build:
6781
name: Test and Build
6882
runs-on: ubuntu-latest

0 commit comments

Comments
 (0)