From 7eab18cd32cbdd5501fae1bfd4e7d4f80585ff8c Mon Sep 17 00:00:00 2001 From: Enkidu93 Date: Thu, 26 Feb 2026 11:39:50 -0500 Subject: [PATCH 1/5] First pass at github action (with testing branch) --- .github/workflows/create-porting-issue.yml | 63 ++++++++++++++++++++++ 1 file changed, 63 insertions(+) create mode 100644 .github/workflows/create-porting-issue.yml diff --git a/.github/workflows/create-porting-issue.yml b/.github/workflows/create-porting-issue.yml new file mode 100644 index 00000000..fb7429f7 --- /dev/null +++ b/.github/workflows/create-porting-issue.yml @@ -0,0 +1,63 @@ +name: Create Porting Issue + +on: + pull_request: + types: [closed] + workflow_dispatch: + +permissions: + contents: read + +jobs: + create-port-issue: + if: github.event.pull_request.merged == true || github.event_name == 'workflow_dispatch' + runs-on: ubuntu-latest + + steps: + - name: Create issue in opposite repository + uses: actions/github-script@v7 + with: + github-token: ${{ secrets.PORTING_API_TOKEN }} + script: | + const owner = context.repo.owner; + const currentRepo = context.repo.repo; + + const otherRepo = currentRepo === "machine" + ? "machine.py" + : "machine"; + + if (context.eventName === "workflow_dispatch") { + await github.rest.issues.create({ + owner, + repo: otherRepo, + title: "Test auto-porting issue", + body: "This is a test", + labels: ["porting"] + }); + } + else { + const prNumber = context.payload.pull_request.number; + const prTitle = context.payload.pull_request.title; + const prUrl = context.payload.pull_request.html_url; + + if (context.payload.pull_request.body?.includes("AUTO-GENERATED-ISSUE")) { + return; + } + + const issueTitle = `Port '${prTitle}'`; + const issueBody = ` + Port any relevant changes in ${prUrl} from ${currentRepo} to ${otherRepo}. + + + `; + + const labelName = "porting"; + + await github.rest.issues.create({ + owner, + repo: otherRepo, + title: issueTitle, + body: issueBody, + labels: [labelName] + }); + } From 9a0a576f6873c3e74fa82e68784af29f5f1d0587 Mon Sep 17 00:00:00 2001 From: Enkidu93 Date: Thu, 26 Feb 2026 13:09:25 -0500 Subject: [PATCH 2/5] Fix recursive checking; test when opening (needs to be removed before merging!) --- .github/workflows/create-porting-issue.yml | 37 +++++++++++++++++----- 1 file changed, 29 insertions(+), 8 deletions(-) diff --git a/.github/workflows/create-porting-issue.yml b/.github/workflows/create-porting-issue.yml index fb7429f7..63d0da87 100644 --- a/.github/workflows/create-porting-issue.yml +++ b/.github/workflows/create-porting-issue.yml @@ -2,15 +2,15 @@ name: Create Porting Issue on: pull_request: - types: [closed] - workflow_dispatch: + types: [closed, opened] permissions: contents: read + issues: write jobs: create-port-issue: - if: github.event.pull_request.merged == true || github.event_name == 'workflow_dispatch' + if: github.event.pull_request.merged == true || github.event.action == 'opened' runs-on: ubuntu-latest steps: @@ -26,7 +26,7 @@ jobs: ? "machine.py" : "machine"; - if (context.eventName === "workflow_dispatch") { + if (context.event.action === "opened") { await github.rest.issues.create({ owner, repo: otherRepo, @@ -40,7 +40,30 @@ jobs: const prTitle = context.payload.pull_request.title; const prUrl = context.payload.pull_request.html_url; - if (context.payload.pull_request.body?.includes("AUTO-GENERATED-ISSUE")) { + const query = ` + query($owner: String!, $repo: String!, $number: Int!) { + repository(owner: $owner, name: $repo) { + pullRequest(number: $number) { + closingIssuesReferences(first: 10) { + nodes { + number + body + } + } + } + } + } + `; + + const result = await github.graphql(query, { + owner, + repo: currentRepo, + number: prNumber + }); + + const closingIssues = result.repository.pullRequest.closingIssuesReferences.nodes; + + if (closingIssues.every(issue => issue.body?.includes("AUTO-GENERATED-ISSUE"))) { return; } @@ -51,13 +74,11 @@ jobs: `; - const labelName = "porting"; - await github.rest.issues.create({ owner, repo: otherRepo, title: issueTitle, body: issueBody, - labels: [labelName] + labels: ["porting"] }); } From e47d0a4e6ddfd17b0a34d7ed5695fc98a8bfad70 Mon Sep 17 00:00:00 2001 From: Enkidu93 Date: Thu, 26 Feb 2026 13:16:23 -0500 Subject: [PATCH 3/5] Fix script typo; make test a little more realistic --- .github/workflows/create-porting-issue.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/create-porting-issue.yml b/.github/workflows/create-porting-issue.yml index 63d0da87..7a9c647c 100644 --- a/.github/workflows/create-porting-issue.yml +++ b/.github/workflows/create-porting-issue.yml @@ -26,12 +26,12 @@ jobs: ? "machine.py" : "machine"; - if (context.event.action === "opened") { + if (context.payload.action === "opened") { await github.rest.issues.create({ owner, repo: otherRepo, title: "Test auto-porting issue", - body: "This is a test", + body: "This is a test. Porting from ${currentRepo} to ${otherRepo}", labels: ["porting"] }); } From 82eaa90076ec2ea42fac2a86697de2bc3989ed4b Mon Sep 17 00:00:00 2001 From: Enkidu93 Date: Thu, 26 Feb 2026 13:23:18 -0500 Subject: [PATCH 4/5] Fix formatting --- .github/workflows/create-porting-issue.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/create-porting-issue.yml b/.github/workflows/create-porting-issue.yml index 7a9c647c..3981519a 100644 --- a/.github/workflows/create-porting-issue.yml +++ b/.github/workflows/create-porting-issue.yml @@ -31,7 +31,7 @@ jobs: owner, repo: otherRepo, title: "Test auto-porting issue", - body: "This is a test. Porting from ${currentRepo} to ${otherRepo}", + body: `This is a test. Porting from ${currentRepo} to ${otherRepo}`, labels: ["porting"] }); } From 0a9004dd98bca24b08a8549185bda0652d8be3f2 Mon Sep 17 00:00:00 2001 From: Enkidu93 Date: Thu, 26 Feb 2026 13:26:37 -0500 Subject: [PATCH 5/5] Remove on 'opened' testing issue --- .github/workflows/create-porting-issue.yml | 63 +++++++++------------- 1 file changed, 26 insertions(+), 37 deletions(-) diff --git a/.github/workflows/create-porting-issue.yml b/.github/workflows/create-porting-issue.yml index 3981519a..e41353d6 100644 --- a/.github/workflows/create-porting-issue.yml +++ b/.github/workflows/create-porting-issue.yml @@ -2,7 +2,7 @@ name: Create Porting Issue on: pull_request: - types: [closed, opened] + types: [closed] permissions: contents: read @@ -10,7 +10,7 @@ permissions: jobs: create-port-issue: - if: github.event.pull_request.merged == true || github.event.action == 'opened' + if: github.event.pull_request.merged == true runs-on: ubuntu-latest steps: @@ -26,19 +26,9 @@ jobs: ? "machine.py" : "machine"; - if (context.payload.action === "opened") { - await github.rest.issues.create({ - owner, - repo: otherRepo, - title: "Test auto-porting issue", - body: `This is a test. Porting from ${currentRepo} to ${otherRepo}`, - labels: ["porting"] - }); - } - else { - const prNumber = context.payload.pull_request.number; - const prTitle = context.payload.pull_request.title; - const prUrl = context.payload.pull_request.html_url; + const prNumber = context.payload.pull_request.number; + const prTitle = context.payload.pull_request.title; + const prUrl = context.payload.pull_request.html_url; const query = ` query($owner: String!, $repo: String!, $number: Int!) { @@ -55,30 +45,29 @@ jobs: } `; - const result = await github.graphql(query, { - owner, - repo: currentRepo, - number: prNumber - }); + const result = await github.graphql(query, { + owner, + repo: currentRepo, + number: prNumber + }); - const closingIssues = result.repository.pullRequest.closingIssuesReferences.nodes; + const closingIssues = result.repository.pullRequest.closingIssuesReferences.nodes; - if (closingIssues.every(issue => issue.body?.includes("AUTO-GENERATED-ISSUE"))) { - return; - } + if (closingIssues.every(issue => issue.body?.includes("AUTO-GENERATED-ISSUE"))) { + return; + } - const issueTitle = `Port '${prTitle}'`; - const issueBody = ` - Port any relevant changes in ${prUrl} from ${currentRepo} to ${otherRepo}. + const issueTitle = `Port '${prTitle}'`; + const issueBody = ` + Port any relevant changes in ${prUrl} from ${currentRepo} to ${otherRepo}. - - `; + + `; - await github.rest.issues.create({ - owner, - repo: otherRepo, - title: issueTitle, - body: issueBody, - labels: ["porting"] - }); - } + await github.rest.issues.create({ + owner, + repo: otherRepo, + title: issueTitle, + body: issueBody, + labels: ["porting"] + });