-
-
Notifications
You must be signed in to change notification settings - Fork 607
55 lines (49 loc) · 1.84 KB
/
issue-for-sre-handoff.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
name: Check PR for configuration and SQL changes
on:
pull_request:
types: [review_requested]
paths:
- 'test/config-next/*.json'
- 'test/config-next/*.yaml'
- 'test/config-next/*.yml'
- 'sa/db-users/*.sql'
- 'sa/db-next/**/*.sql'
- 'sa/db/**/*.sql'
jobs:
check-changes:
runs-on: ubuntu-latest
permissions:
pull-requests: write
steps:
- name: Comment PR
uses: actions/github-script@v7
with:
script: |
const commentMarker = '<!-- deployment_ticket_check -->';
const prAuthor = context.payload.pull_request.user.login;
const commentBody = `${commentMarker}\n@${prAuthor}, this PR appears to contain configuration and/or SQL schema changes. Please ensure that a corresponding deployment ticket has been filed with the new values.\n`;
const { owner, repo, number: issue_number } = context.issue;
const issueRegexp = /IN-\d+/;
// Get PR body and all issue comments.
const prBody = context.payload.pull_request.body;
const comments = await github.rest.issues.listComments({
owner,
repo,
issue_number
});
if (issueRegexp.test(prBody) || comments.data.some(c => issueRegexp.test(c.body))) {
// Issue number exists in PR body or comments.
return;
}
if (comments.data.find(c => c.body.includes(commentMarker))) {
// Comment already exists.
return;
}
// No issue number or comment were found, post the comment.
await github.rest.issues.createComment({
owner,
repo,
issue_number,
body: commentBody
});
github-token: ${{ secrets.GITHUB_TOKEN }}