Skip to content

Commit 115d582

Browse files
gcf-owl-bot[bot]sofisl
authored andcommitted
1 parent 86e5e1f commit 115d582

File tree

1 file changed

+5
-8
lines changed

1 file changed

+5
-8
lines changed

.github/scripts/close-invalid-link.cjs

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,16 +17,16 @@ async function closeIssue(github, owner, repo, number) {
1717
owner: owner,
1818
repo: repo,
1919
issue_number: number,
20-
body: "Issue was opened with an invalid reproduction link. Please make sure the repository is a valid, publicly-accessible github repository, and make sure the url is complete (example: https://github.com/googleapis/google-cloud-node)"
20+
body: 'Issue was opened with an invalid reproduction link. Please make sure the repository is a valid, publicly-accessible github repository, and make sure the url is complete (example: https://github.com/googleapis/google-cloud-node)'
2121
});
2222
await github.rest.issues.update({
2323
owner: owner,
2424
repo: repo,
2525
issue_number: number,
26-
state: "closed"
26+
state: 'closed'
2727
});
2828
}
29-
module.exports = async ({ github, context }) => {
29+
module.exports = async ({github, context}) => {
3030
const owner = context.repo.owner;
3131
const repo = context.repo.repo;
3232
const number = context.issue.number;
@@ -37,15 +37,12 @@ module.exports = async ({ github, context }) => {
3737
issue_number: number,
3838
});
3939

40-
const isBugTemplate = issue.data.body.includes("Link to the code that reproduces this issue");
40+
const isBugTemplate = issue.data.body.includes('Link to the code that reproduces this issue');
4141

4242
if (isBugTemplate) {
43-
console.log(`Issue ${number} is a bug template`)
4443
try {
45-
const link = issue.data.body.split("\n")[18].match(/(https?:\/\/(gist\.)?github.com\/.*)/)[0];
46-
console.log(`Issue ${number} contains this link: ${link}`)
44+
const link = issue.data.body.split('\n')[18].match(/(https?:\/\/g?i?s?t?\.?github.com\/.*)/);
4745
const isValidLink = (await fetch(link)).ok;
48-
console.log(`Issue ${number} has a ${isValidLink ? "valid" : "invalid"} link`)
4946
if (!isValidLink) {
5047
await closeIssue(github, owner, repo, number);
5148
}

0 commit comments

Comments
 (0)