Skip to content

Add https://search.xmr.st #238

Add https://search.xmr.st

Add https://search.xmr.st #238

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'
})
}