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>
55 lines
1.9 KiB
YAML
55 lines
1.9 KiB
YAML
name: "Linkify systeminfo bundles"
|
|
on:
|
|
issue_comment:
|
|
types: [created, edited]
|
|
|
|
jobs:
|
|
linkifyBundles:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/github-script@v7
|
|
with:
|
|
github-token: ${{ secrets.GITHUB_TOKEN }}
|
|
script: |
|
|
let comment = context.payload.comment.body;
|
|
|
|
const botMarker = "<!-- linkify_bundles -->";
|
|
const botWasHere = comment.indexOf(botMarker);
|
|
if (botWasHere !== -1) {
|
|
comment = comment.substring(0, botWasHere);
|
|
};
|
|
|
|
const bundleRegex = /\[(octoprint-systeminfo-\d{14}\.zip)\]\(([^)]+)\)/g;
|
|
|
|
const bundles = [];
|
|
const seen = [];
|
|
const matches = comment.matchAll(bundleRegex);
|
|
for (const match of matches) {
|
|
if (!seen.includes(match[1])) {
|
|
bundles.push({filename: match[1], link: match[2], match: match[0]});
|
|
seen.push(match[1]);
|
|
}
|
|
};
|
|
|
|
if (bundles.length > 0) {
|
|
let text = comment + botMarker + "\n\n---\n\n\nBundles:\n\n";
|
|
bundles.forEach((bundle) => {
|
|
text += " * [" + bundle.filename + "](https://bundleviewer.octoprint.org/?url=" + encodeURIComponent(bundle.link) + ")\n"
|
|
});
|
|
text += "\n*edited by @github-actions to add bundle viewer links*\n";
|
|
|
|
github.rest.issues.updateComment({
|
|
owner: context.repo.owner,
|
|
repo: context.repo.repo,
|
|
comment_id: context.payload.comment.id,
|
|
body: text
|
|
});
|
|
} else if (botWasHere !== -1) {
|
|
github.rest.issues.updateComment({
|
|
owner: context.repo.owner,
|
|
repo: context.repo.repo,
|
|
comment_id: context.payload.comment.id,
|
|
body: comment
|
|
});
|
|
}
|