1
- name : On PR opened
1
+ name : On PR open
2
2
3
3
on :
4
4
workflow_run :
9
9
env :
10
10
BLOCK_LABEL : " do-not-merge"
11
11
BLOCK_REASON_LABEL : " need-issue"
12
+ IGNORE_AUTHORS : ' ["dependabot[bot]", "markdownify[bot]"]'
12
13
13
- # TODO: include markdownify author too
14
14
jobs :
15
15
get_pr_details :
16
16
if : ${{ github.event.workflow_run.conclusion == 'success' }}
@@ -22,41 +22,19 @@ jobs:
22
22
check_related_issue :
23
23
needs : get_pr_details
24
24
if : >
25
- ${{ needs.get_pr_details.outputs.prAuthor != 'dependabot[bot] ' &&
26
- needs.get_pr_details.outputs.prAction == 'opened'
25
+ ${{ needs.get_pr_details.outputs.prAction == 'opened ' &&
26
+ contains(fromJson(env.IGNORE_AUTHORS), needs.get_pr_details.outputs.prAuthor) != true
27
27
}}
28
28
runs-on : ubuntu-latest
29
29
steps :
30
+ - uses : actions/checkout@v3
30
31
- name : " Ensure related issue is present"
31
32
uses : actions/github-script@v6
33
+ env :
34
+ PR_BODY : ${{ needs.get_pr_details.outputs.prBody }}
35
+ PR_NUMBER : ${{ needs.get_pr_details.outputs.prNumber }}
32
36
with :
33
37
github-token : ${{ secrets.GITHUB_TOKEN }}
34
- # Maintenance: convert into a standalone JS like post_release.js
35
38
script : |
36
- const prBody = "${{ needs.get_pr_details.outputs.prBody }}";
37
- const prNumber = ${{ needs.get_pr_details.outputs.prNumber }};
38
- const blockLabel = process.env.BLOCK_LABEL;
39
- const blockReasonLabel = process.env.BLOCK_REASON_LABEL;
40
-
41
- const RELATED_ISSUE_REGEX = /Issue number:.+(\d)/
42
-
43
- const matcher = new RegExp(RELATED_ISSUE_REGEX)
44
- const isMatch = matcher.exec(prBody)
45
- if (isMatch == null) {
46
- console.info(`No related issue found, maybe the author didn't use the template but there is one.`)
47
-
48
- let msg = "No related issues found. Please ensure there is an open issue related to this change to avoid significant delays or closure.";
49
- await github.rest.issues.createComment({
50
- owner: context.repo.owner,
51
- repo: context.repo.repo,
52
- body: msg,
53
- issue_number: prNumber,
54
- });
55
-
56
- await github.rest.issues.addLabels({
57
- issue_number: prNumber,
58
- owner: context.repo.owner,
59
- repo: context.repo.repo,
60
- labels: [blockLabel, blockReasonLabel]
61
- })
62
- }
39
+ const script = require('.github/scripts/label_missing_related_issue.js')
40
+ await script({github, context, core})
0 commit comments