2023-05-08 11:08:04 +00:00
name : Add instance to uptimerobot
on :
issues :
types : [ opened, reopened]
jobs :
replycomment :
runs-on : ubuntu-latest
permissions : write-all
steps :
- uses : actions/checkout@v3
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 request 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) {
if (issueInfo.title.includes(".onion")) {
var replyComment =
2023-09-12 15:26:43 +00:00
[ 'Hello! I have detected that you are requesting to add an onion URL.' ,
2023-05-08 11:08:04 +00:00
'Please create a pull request instead for adding your onion url as an alternative to your clearnet URL : https://github.com/iv-org/documentation/edit/master/docs/instances.md'
] .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'
});
}
else {
var instanceHostname = (new URL(issueTitleParseUrl[0].href)).hostname;
var request = require("request");
var options = { method: 'POST',
url : 'https://api.uptimerobot.com/v2/newMonitor' ,
2024-04-21 22:20:29 +00:00
json:true,
2023-05-08 11:08:04 +00:00
headers :
{ 'content-type' : 'application/x-www-form-urlencoded' ,
'cache-control' : 'no-cache' },
form :
{ api_key : '${{ secrets.UPTIMEROBOT_API_KEY }}' ,
format : 'json' ,
type : '1' ,
url : 'https://' + instanceHostname,
friendly_name : instanceHostname } };
request(options, async function (error, response, body) {
if (error) throw new Error(error);
console.log(body);
if (body.stat == "ok") {
var replyComment =
['Hello! Your instance has been added to our monitoring system : https://stats.uptimerobot.com/89VnzSKAn/' + body.monitor.id,
2023-06-03 17:17:45 +00:00
'You need to wait 30 days before we add your instance, this is to evaluate that your instance will keep a good uptime for one month.' ,
2023-05-08 11:08:04 +00:00
'' ,
2023-08-24 16:10:21 +00:00
'Make sure you double checked all the mandatory checks or this will slow down the process of adding your instance!' ,
'' ,
2023-11-21 13:28:17 +00:00
'Please consult these two important tutorials:' ,
'' ,
'- Escaping the YouTube block ([403 errors in playback](https://github.com/iv-org/invidious/issues/4045)) : https://docs.invidious.io/ipv6-rotator/',
'' ,
'- Improving the performance and the stability of your public instance : https://docs.invidious.io/improve-public-instance/',
'' ,
'It is highly recommended to follow these tutorials because it will allow the instance to stay stable and performant over the long term.' ,
'' ,
2024-04-15 13:58:00 +00:00
'When your instance is added to the instances list, please consider joining the Matrix room for public instance maintainers by joining our Matrix room : https://matrix.to/#/#invidious:matrix.org',
'and pinging @ unixfox, @ TheFrenchGhosty and @ SamantazFox to ask to be invited to it.' ,
'We discuss troubles managing a public instance, we share some advices, we warn you in advance of potential security issues and more.'
2023-05-08 11:08:04 +00:00
] .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.addLabels({
issue_number : context.issue.number,
owner : context.repo.owner,
repo : context.repo.repo,
labels : [ 'wait-30-days' ]
})
}
});
}
}
else {
var replyComment =
2023-05-19 22:13:26 +00:00
[ 'Domain not detected in the title, please edit the title by correcting it like this:' ,
2023-05-08 11:08:04 +00:00
'Issue title example : `[New instance] 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
})
2023-05-19 22:13:26 +00:00
}