-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
101 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
name: "Issue Automation" | ||
on: | ||
issues: | ||
types: [opened, edited, closed, reopened, labeled, unlabeled] | ||
|
||
jobs: | ||
issue-automation: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/github-script@v7 | ||
env: | ||
REMINDER: > | ||
Hi @${{ github.event.issue.user.login }}! | ||
It looks like you didn't upload a [system info bundle](https://community.octoprint.org/t/29887) as requested by the template. | ||
A bundle is required to further process your issue. It contains important logs and | ||
system information to be able to put your issue into context and give pointers as to | ||
what has happened. | ||
Please **edit your original post above** and upload **a bundle zip file**. Actually upload the file please and | ||
do not paste some link to a cloud provider, we want to have everything in one place here. Also do | ||
not unpack, repack or otherwise modify the bundle or its name, share it **exactly** like you get it from OctoPrint. | ||
Without the availability of a bundle, your issue will have to be closed. | ||
Thank you for your collaboration. | ||
THANKYOU: > | ||
Thank you @${{ github.event.issue.user.login }} for adding a bundle! Now this can actually get looked at. | ||
with: | ||
script: | | ||
const { REMINDER, THANKYOU } = process.env; | ||
const bundleRegex = /\[(octoprint-systeminfo-\d{14}\.zip)\]\(([^)]+)\)/g; | ||
const marker = "<!-- check_for_bundle -->"; | ||
const issueLabels = await github.rest.issues.listLabelsOnIssue({ | ||
owner: context.repo.owner, | ||
repo: context.repo.repo, | ||
issue_number: context.issue.number | ||
}); | ||
let labels = issueLabels.data.map(label => label.name); | ||
const comments = await github.rest.issues.listComments({ | ||
owner: context.repo.owner, | ||
repo: context.repo.repo, | ||
issue_number: context.issue.number, | ||
}) | ||
const comment = comments.data.find(c => c.user.login === "github-actions[bot]" && c.body.includes(marker)); | ||
if (comment) { | ||
console.log("Found comment, id=" + comment.id); | ||
} else { | ||
console.log("No comment found"); | ||
} | ||
if (!labels.includes("triage") || !labels.includes("bug") || labels.includes("approved")) { | ||
console.log("Deleting comment if it exists..."); | ||
if (comment) { | ||
await github.rest.issues.deleteComment({ | ||
owner: context.repo.owner, | ||
repo: context.repo.repo, | ||
comment_id: comment.id, | ||
}) | ||
} | ||
return; | ||
} | ||
const found = !!context.payload.issue.body.match(bundleRegex); | ||
if (!found) { | ||
console.log("No bundle found, posting/updating reminder"); | ||
const text = REMINDER + "\n" + marker; | ||
if (!comment) { | ||
await github.rest.issues.createComment({ | ||
owner: context.repo.owner, | ||
repo: context.repo.repo, | ||
issue_number: context.issue.number, | ||
body: text | ||
}); | ||
} else if (comment.body !== text) { | ||
await github.rest.issues.updateComment({ | ||
owner: context.repo.owner, | ||
repo: context.repo.repo, | ||
comment_id: comment.id, | ||
body: text | ||
}); | ||
} | ||
} else if (found && comment) { | ||
console.log("Bundle found, saying thanks"); | ||
const text = REMINDER.split("\n\n").map(line => `~~${line.trim()}~~`).join("\n\n") + "\n\n" + THANKYOU + "\n" + marker; | ||
if (comment.body !== text) { | ||
await github.rest.issues.updateComment({ | ||
owner: context.repo.owner, | ||
repo: context.repo.repo, | ||
comment_id: comment.id, | ||
body: text | ||
}); | ||
} | ||
} |