Delete https://search.charliewhiskey.net #222
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
name: Detect instances previously submitted | |
on: | |
issues: | |
types: [opened] | |
jobs: | |
replycomment: | |
runs-on: ubuntu-latest | |
permissions: write-all | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
if: contains(github.event.issue.labels.*.name, 'instance add') | |
- uses: actions/setup-node@v3 | |
if: contains(github.event.issue.labels.*.name, 'instance add') | |
with: | |
node-version: 16 | |
- run: npm install linkifyjs | |
if: contains(github.event.issue.labels.*.name, 'instance add') | |
- uses: actions/github-script@v6 | |
if: contains(github.event.issue.labels.*.name, 'instance add') | |
with: | |
script: | | |
var issueInfo = (await github.rest.issues.get({ | |
issue_number: context.issue.number, | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
})).data; | |
var linkify = require("linkifyjs"); | |
var issueTitleParseUrl = linkify.find(issueInfo.title); | |
if (issueTitleParseUrl.length !== 0) { | |
var instanceHostname = (new URL(issueTitleParseUrl[0].href)).hostname; | |
let myOutput = ''; | |
let myError = ''; | |
const options = {}; | |
options.listeners = { | |
stdout: (data) => { | |
myOutput += data.toString(); | |
}, | |
stderr: (data) => { | |
myError += data.toString(); | |
} | |
}; | |
await exec.exec('git', ['log', '-S', instanceHostname, '--pretty=format:Commit ID: %H%n - Date: %ad%n - Description: %s%n - Author: %an%n'], options); | |
if (myOutput !== "") { | |
var replyComment = | |
['@maintainers Warning, instance found in the commit history, make sure to wait 1 week before adding the instance if needed.', | |
'See here for more information: https://github.com/searxng/searx-instances#add-a-previously-submitted-instance', | |
'', | |
'```', | |
].join('\n'); | |
replyComment = replyComment + "\n" + myOutput + "```"; | |
await github.rest.issues.createComment({ | |
issue_number: context.issue.number, | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
body: replyComment | |
}) | |
} | |
} | |
else { | |
var replyComment = | |
['Domain not detected in the title, please edit the title by correcting it like this and reopen the issue:', | |
'Issue title example: `Add https://myinstance.com`' | |
].join('\n'); | |
await github.rest.issues.createComment({ | |
issue_number: context.issue.number, | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
body: replyComment | |
}) | |
await github.rest.issues.update({ | |
issue_number: context.issue.number, | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
state: 'closed' | |
}) | |
} |