Skip to content

Commit a306457

Browse files
committed
👷 Add bundle check workflow
1 parent abedb6f commit a306457

File tree

1 file changed

+101
-0
lines changed

1 file changed

+101
-0
lines changed
Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
name: "Issue Automation"
2+
on:
3+
issues:
4+
types: [opened, edited, closed, reopened, labeled, unlabeled]
5+
6+
jobs:
7+
issue-automation:
8+
runs-on: ubuntu-latest
9+
steps:
10+
- uses: actions/github-script@v7
11+
env:
12+
REMINDER: >
13+
Hi @${{ github.event.issue.user.login }}!
14+
15+
16+
It looks like you didn't upload a [system info bundle](https://community.octoprint.org/t/29887) as requested by the template.
17+
A bundle is required to further process your issue. It contains important logs and
18+
system information to be able to put your issue into context and give pointers as to
19+
what has happened.
20+
21+
22+
Please **edit your original post above** and upload **a bundle zip file**. Actually upload the file please and
23+
do not paste some link to a cloud provider, we want to have everything in one place here. Also do
24+
not unpack, repack or otherwise modify the bundle or its name, share it **exactly** like you get it from OctoPrint.
25+
26+
27+
Without the availability of a bundle, your issue will have to be closed.
28+
29+
30+
Thank you for your collaboration.
31+
THANKYOU: >
32+
Thank you @${{ github.event.issue.user.login }} for adding a bundle! Now this can actually get looked at.
33+
with:
34+
script: |
35+
const { REMINDER, THANKYOU } = process.env;
36+
const bundleRegex = /\[(octoprint-systeminfo-\d{14}\.zip)\]\(([^)]+)\)/g;
37+
const marker = "<!-- check_for_bundle -->";
38+
39+
const issueLabels = await github.rest.issues.listLabelsOnIssue({
40+
owner: context.repo.owner,
41+
repo: context.repo.repo,
42+
issue_number: context.issue.number
43+
});
44+
let labels = issueLabels.data.map(label => label.name);
45+
46+
const comments = await github.rest.issues.listComments({
47+
owner: context.repo.owner,
48+
repo: context.repo.repo,
49+
issue_number: context.issue.number,
50+
})
51+
const comment = comments.data.find(c => c.user.login === "github-actions[bot]" && c.body.includes(marker));
52+
if (comment) {
53+
console.log("Found comment, id=" + comment.id);
54+
} else {
55+
console.log("No comment found");
56+
}
57+
58+
if (!labels.includes("triage") || !labels.includes("bug") || labels.includes("approved")) {
59+
console.log("Deleting comment if it exists...");
60+
if (comment) {
61+
await github.rest.issues.deleteComment({
62+
owner: context.repo.owner,
63+
repo: context.repo.repo,
64+
comment_id: comment.id,
65+
})
66+
}
67+
return;
68+
}
69+
70+
const found = !!context.payload.issue.body.match(bundleRegex);
71+
72+
if (!found) {
73+
console.log("No bundle found, posting/updating reminder");
74+
const text = REMINDER + "\n" + marker;
75+
if (!comment) {
76+
await github.rest.issues.createComment({
77+
owner: context.repo.owner,
78+
repo: context.repo.repo,
79+
issue_number: context.issue.number,
80+
body: text
81+
});
82+
} else if (comment.body !== text) {
83+
await github.rest.issues.updateComment({
84+
owner: context.repo.owner,
85+
repo: context.repo.repo,
86+
comment_id: comment.id,
87+
body: text
88+
});
89+
}
90+
} else if (found && comment) {
91+
console.log("Bundle found, saying thanks");
92+
const text = REMINDER.split("\n\n").map(line => `~~${line.trim()}~~`).join("\n\n") + "\n\n" + THANKYOU + "\n" + marker;
93+
if (comment.body !== text) {
94+
await github.rest.issues.updateComment({
95+
owner: context.repo.owner,
96+
repo: context.repo.repo,
97+
comment_id: comment.id,
98+
body: text
99+
});
100+
}
101+
}

0 commit comments

Comments
 (0)