File tree Expand file tree Collapse file tree 1 file changed +73
-0
lines changed
Expand file tree Collapse file tree 1 file changed +73
-0
lines changed Original file line number Diff line number Diff line change 1+ name : Create Porting Issue
2+
3+ on :
4+ pull_request :
5+ types : [closed]
6+
7+ permissions :
8+ contents : read
9+ issues : write
10+
11+ jobs :
12+ create-port-issue :
13+ if : github.event.pull_request.merged == true
14+ runs-on : ubuntu-latest
15+
16+ steps :
17+ - name : Create issue in opposite repository
18+ uses : actions/github-script@v7
19+ with :
20+ github-token : ${{ secrets.PORTING_API_TOKEN }}
21+ script : |
22+ const owner = context.repo.owner;
23+ const currentRepo = context.repo.repo;
24+
25+ const otherRepo = currentRepo === "machine"
26+ ? "machine.py"
27+ : "machine";
28+
29+ const prNumber = context.payload.pull_request.number;
30+ const prTitle = context.payload.pull_request.title;
31+ const prUrl = context.payload.pull_request.html_url;
32+
33+ const query = `
34+ query($owner: String!, $repo: String!, $number: Int!) {
35+ repository(owner: $owner, name: $repo) {
36+ pullRequest(number: $number) {
37+ closingIssuesReferences(first: 10) {
38+ nodes {
39+ number
40+ body
41+ }
42+ }
43+ }
44+ }
45+ }
46+ `;
47+
48+ const result = await github.graphql(query, {
49+ owner,
50+ repo: currentRepo,
51+ number: prNumber
52+ });
53+
54+ const closingIssues = result.repository.pullRequest.closingIssuesReferences.nodes;
55+
56+ if (closingIssues.length > 0 && closingIssues.every(issue => issue.body?.includes("AUTO-GENERATED-ISSUE"))) {
57+ return;
58+ }
59+
60+ const issueTitle = `Port '${prTitle}'`;
61+ const issueBody = `
62+ Port any relevant changes in ${prUrl} from ${currentRepo} to ${otherRepo}.
63+
64+ <!-- AUTO-GENERATED-ISSUE -->
65+ `;
66+
67+ await github.rest.issues.create({
68+ owner,
69+ repo: otherRepo,
70+ title: issueTitle,
71+ body: issueBody,
72+ labels: ["porting"]
73+ });
You can’t perform that action at this time.
0 commit comments