-
Notifications
You must be signed in to change notification settings - Fork 0
59 lines (56 loc) · 1.94 KB
/
pr_comment.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
name: PR comments
on:
workflow_run:
workflows:
- CI jobs
types:
- completed
permissions:
pull-requests: write
jobs:
spell-check-comment:
runs-on: ubuntu-latest
if: >
github.event.workflow_run.event == 'pull_request' &&
github.event.workflow_run.conclusion == 'success'
steps:
- name: Find associated pull request
# https://github.com/orgs/community/discussions/25220#discussioncomment-8697399
id: pr
uses: actions/github-script@v7
with:
script: |
const response = await github.rest.search.issuesAndPullRequests({
q: 'repo:${{ github.repository }} is:pr sha:${{ github.event.workflow_run.head_sha }}',
per_page: 1,
});
const items = response.data.items;
if (items.length < 1) {
console.error('No PRs found');
return
}
const pullRequestNumber = items[0].number;
console.info("Pull request number is", pullRequestNumber);
return pullRequestNumber;
- name: Download spell check report
uses: actions/download-artifact@v4
with:
github-token: ${{ github.token }}
name: Spell check report
run-id: ${{ github.event.workflow_run.id }}
- name: Check if spell check failed
id: spell-check
run: |
lines=$(wc -l spell_check_report.md | cut -d ' ' -f1)
if [[ ${lines} -gt 1 ]]; then
echo "failed=true" >> "${GITHUB_OUTPUT}"
else
echo "failed=false" >> "${GITHUB_OUTPUT}"
fi
- name: Post spell check PR comment
uses: thollander/actions-comment-pull-request@v3
with:
comment-tag: spell-check-failed
file-path: spell_check_report.md
mode: ${{ steps.spell-check.outputs.failed == 'true' && 'upsert' || 'delete' }}
pr-number: ${{ steps.pr.outputs.result }}