Skip to content

Commit 9a0a576

Browse files
committed
Fix recursive checking; test when opening (needs to be removed before merging!)
1 parent 7eab18c commit 9a0a576

File tree

1 file changed

+29
-8
lines changed

1 file changed

+29
-8
lines changed

.github/workflows/create-porting-issue.yml

Lines changed: 29 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,15 @@ name: Create Porting Issue
22

33
on:
44
pull_request:
5-
types: [closed]
6-
workflow_dispatch:
5+
types: [closed, opened]
76

87
permissions:
98
contents: read
9+
issues: write
1010

1111
jobs:
1212
create-port-issue:
13-
if: github.event.pull_request.merged == true || github.event_name == 'workflow_dispatch'
13+
if: github.event.pull_request.merged == true || github.event.action == 'opened'
1414
runs-on: ubuntu-latest
1515

1616
steps:
@@ -26,7 +26,7 @@ jobs:
2626
? "machine.py"
2727
: "machine";
2828
29-
if (context.eventName === "workflow_dispatch") {
29+
if (context.event.action === "opened") {
3030
await github.rest.issues.create({
3131
owner,
3232
repo: otherRepo,
@@ -40,7 +40,30 @@ jobs:
4040
const prTitle = context.payload.pull_request.title;
4141
const prUrl = context.payload.pull_request.html_url;
4242
43-
if (context.payload.pull_request.body?.includes("AUTO-GENERATED-ISSUE")) {
43+
const query = `
44+
query($owner: String!, $repo: String!, $number: Int!) {
45+
repository(owner: $owner, name: $repo) {
46+
pullRequest(number: $number) {
47+
closingIssuesReferences(first: 10) {
48+
nodes {
49+
number
50+
body
51+
}
52+
}
53+
}
54+
}
55+
}
56+
`;
57+
58+
const result = await github.graphql(query, {
59+
owner,
60+
repo: currentRepo,
61+
number: prNumber
62+
});
63+
64+
const closingIssues = result.repository.pullRequest.closingIssuesReferences.nodes;
65+
66+
if (closingIssues.every(issue => issue.body?.includes("AUTO-GENERATED-ISSUE"))) {
4467
return;
4568
}
4669
@@ -51,13 +74,11 @@ jobs:
5174
<!-- AUTO-GENERATED-ISSUE -->
5275
`;
5376
54-
const labelName = "porting";
55-
5677
await github.rest.issues.create({
5778
owner,
5879
repo: otherRepo,
5980
title: issueTitle,
6081
body: issueBody,
61-
labels: [labelName]
82+
labels: ["porting"]
6283
});
6384
}

0 commit comments

Comments
 (0)