From 71b787f4f735bb57a116f0743d459d00d3e0ff21 Mon Sep 17 00:00:00 2001 From: Enkidu93 Date: Thu, 26 Feb 2026 11:43:41 -0500 Subject: [PATCH 1/3] 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 0000000..fb7429f --- /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 52e5de1cce272452823d6d5cbfc495d62e49f239 Mon Sep 17 00:00:00 2001 From: Enkidu93 Date: Thu, 26 Feb 2026 13:09:19 -0500 Subject: [PATCH 2/3] 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 fb7429f..63d0da8 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 9fa816a6008d569593bef0828d6dd602bc92efd0 Mon Sep 17 00:00:00 2001 From: Enkidu93 Date: Thu, 26 Feb 2026 13:27:07 -0500 Subject: [PATCH 3/3] Update script with changes from machine --- .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 63d0da8..e41353d 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.event.action === "opened") { - 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; + 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"] + });