Bumps [actions/github-script](https://github.com/actions/github-script) from 6 to 7. - [Release notes](https://github.com/actions/github-script/releases) - [Commits](https://github.com/actions/github-script/compare/v6...v7) --- updated-dependencies: - dependency-name: actions/github-script dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
167 lines
6.3 KiB
YAML
167 lines
6.3 KiB
YAML
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
|
|
with:
|
|
github-token: ${{ secrets.GITHUB_TOKEN }}
|
|
script: |
|
|
let labels = context.payload.issue.labels.map(label => label.name);
|
|
let setLabels = false;
|
|
|
|
switch (context.payload.action) {
|
|
|
|
case 'opened':
|
|
case 'edited': {
|
|
if (context.payload.issue.title.match(/\[request\]|feature request/i)) {
|
|
labels.push('request');
|
|
labels = labels.filter(label => label !== 'triage');
|
|
setLabels = true;
|
|
}
|
|
if (context.payload.issue.title.match(/\[rc feedback\]/i)) {
|
|
labels.push('rc feedback');
|
|
labels = labels.filter(label => label !== 'triage');
|
|
setLabels = true;
|
|
}
|
|
if (context.payload.issue.title.match(/\[task\]/i)) {
|
|
labels.push('task');
|
|
labels = labels.filter(label => label !== 'triage');
|
|
setLabels = true;
|
|
}
|
|
|
|
if (labels.length === 0) {
|
|
labels.push('triage');
|
|
setLabels = true;
|
|
}
|
|
break;
|
|
}
|
|
|
|
case 'closed': {
|
|
if (labels.includes('bug') || labels.includes('request') || labels.includes('improvement') || labels.includes('task')) {
|
|
labels.push('done');
|
|
setLabels = true;
|
|
}
|
|
break;
|
|
}
|
|
|
|
case 'reopened': {
|
|
if (labels.includes('done')) {
|
|
labels = labels.filter(label => label !== 'done');
|
|
setLabels = true;
|
|
}
|
|
break;
|
|
}
|
|
}
|
|
|
|
if (setLabels) {
|
|
github.rest.issues.setLabels({
|
|
issue_number: context.issue.number,
|
|
owner: context.repo.owner,
|
|
repo: context.repo.repo,
|
|
labels: labels
|
|
})
|
|
}
|
|
|
|
#- uses: OctoPrint/actions/issue-validation@main
|
|
# if: github.event_name == 'issues' && (github.event.action == 'opened' || github.event.action == 'edited')
|
|
# with:
|
|
# repo-token: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
- 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("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
|
|
});
|
|
}
|
|
}
|