-
Notifications
You must be signed in to change notification settings - Fork 29
34 lines (32 loc) · 1.04 KB
/
diff_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
name: OpenAPI diff comment
on:
workflow_run:
workflows: ["Lint and validate OpenAPI specs"]
types: [completed]
jobs:
comment:
runs-on: ubuntu-latest
if: github.event.workflow_run.outputs.diff_generated
permissions:
issues: write
steps:
- name: Get the PR number
id: get_pr_number
run: |
echo "pr_number=$(jq '.workflow_run.pull_requests[0].number' $GITHUB_EVENT_PATH)" >> $GITHUB_OUTPUT
- name: Download diff
uses: actions/download-artifact@v4
with:
name: openapi-diff-log
workflow: 'Lint and validate OpenAPI specs'
- name: Create PR comment
uses: actions/github-script@v7
with:
script: |
const diff = require('fs').readFileSync('diff.md', 'utf8');
github.rest.issues.createComment({
issue_number: steps.get_pr_number.outputs.pr_number,
owner: context.repo.owner,
repo: context.repo.repo,
body: '## OpenAPI diff:\n\n' + diff
})