renovate/tools/dispatch-release.mjs

38 lines
911 B
JavaScript
Raw Normal View History

2020-03-10 20:23:41 +00:00
import got from 'got';
import shell from 'shelljs';
2020-03-11 09:11:01 +00:00
import { program } from './utils.mjs';
2020-03-11 07:52:41 +00:00
const version = program.release;
const dry = program.dryRun;
2020-03-10 20:23:41 +00:00
shell.echo(`Dispatching version: ${version}`);
2020-03-11 07:52:41 +00:00
(async () => {
2020-03-11 07:52:41 +00:00
if (dry) {
shell.echo('DRY-RUN: done.');
2020-03-11 07:52:41 +00:00
return;
}
await got(
`https://api.github.com/repos/${process.env.GITHUB_REPOSITORY}/dispatches`,
{
headers: {
'user-agent': 'Renovate release helper',
authorization: `token ${process.env.GITHUB_TOKEN}`,
},
method: 'POST',
json: {
event_type: 'renovate-release',
// max 10 keys here, https://github.com/peter-evans/repository-dispatch#client-payload
client_payload: {
sha: process.env.GITHUB_SHA,
ref: process.env.GITHUB_REF,
version,
},
2020-03-10 20:23:41 +00:00
},
}
);
})().catch((e) => {
// Ignore for now
shell.echo(e.toString());
});