Skip to content

Commit 71b787f

Browse files
committed
First pass at github action (with testing branch)
1 parent 6556252 commit 71b787f

File tree

1 file changed

+63
-0
lines changed

1 file changed

+63
-0
lines changed
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
name: Create Porting Issue
2+
3+
on:
4+
pull_request:
5+
types: [closed]
6+
workflow_dispatch:
7+
8+
permissions:
9+
contents: read
10+
11+
jobs:
12+
create-port-issue:
13+
if: github.event.pull_request.merged == true || github.event_name == 'workflow_dispatch'
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+
if (context.eventName === "workflow_dispatch") {
30+
await github.rest.issues.create({
31+
owner,
32+
repo: otherRepo,
33+
title: "Test auto-porting issue",
34+
body: "This is a test",
35+
labels: ["porting"]
36+
});
37+
}
38+
else {
39+
const prNumber = context.payload.pull_request.number;
40+
const prTitle = context.payload.pull_request.title;
41+
const prUrl = context.payload.pull_request.html_url;
42+
43+
if (context.payload.pull_request.body?.includes("AUTO-GENERATED-ISSUE")) {
44+
return;
45+
}
46+
47+
const issueTitle = `Port '${prTitle}'`;
48+
const issueBody = `
49+
Port any relevant changes in ${prUrl} from ${currentRepo} to ${otherRepo}.
50+
51+
<!-- AUTO-GENERATED-ISSUE -->
52+
`;
53+
54+
const labelName = "porting";
55+
56+
await github.rest.issues.create({
57+
owner,
58+
repo: otherRepo,
59+
title: issueTitle,
60+
body: issueBody,
61+
labels: [labelName]
62+
});
63+
}

0 commit comments

Comments
 (0)