-
Notifications
You must be signed in to change notification settings - Fork 2k
Expand file tree
/
Copy pathcheck_generated_vrl_docs_comment.yml
More file actions
62 lines (56 loc) · 2.1 KB
/
check_generated_vrl_docs_comment.yml
File metadata and controls
62 lines (56 loc) · 2.1 KB
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
60
61
62
name: Comment on PR (Generated VRL Docs)
on:
workflow_run:
workflows: ["Check Generated VRL Docs Freshness"]
types:
- completed
permissions:
contents: read
jobs:
comment:
runs-on: ubuntu-latest
if: >
github.event.workflow_run.conclusion == 'failure'
&& github.event.workflow_run.event == 'pull_request'
permissions:
pull-requests: write
steps:
- name: Download PR metadata
uses: actions/download-artifact@37930b1c2abaa49bbe596cd826c3c89aef350131 # v7.0.0
with:
name: vrl-docs-check-pr
run-id: ${{ github.event.workflow_run.id }}
github-token: ${{ github.token }}
- name: Comment on PR
uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0
with:
script: |
const fs = require('fs');
const prNumber = parseInt(fs.readFileSync('pr-number', 'utf8').trim(), 10);
if (isNaN(prNumber)) {
core.setFailed('Invalid PR number');
return;
}
const marker = '<!-- generated-vrl-docs-check -->';
const body = marker + '\nThe `docs/generated/` folder is out of date but I was unable to push the fix automatically.\n\nPlease run the following and commit the result:\n\n```\nmake generate-vector-vrl-docs\n```';
const { data: comments } = await github.rest.issues.listComments({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: prNumber,
});
const existing = comments.find(c => c.body.startsWith(marker));
if (existing) {
await github.rest.issues.updateComment({
owner: context.repo.owner,
repo: context.repo.repo,
comment_id: existing.id,
body,
});
} else {
await github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: prNumber,
body,
});
}