-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathindex.js
41 lines (34 loc) · 1.22 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
const core = require("@actions/core");
const { request } = require("@octokit/request");
async function run() {
try {
const token = core.getInput("token");
const eventType = core.getInput("event-type");
core.debug(`Event type: ${eventType}`);
// get owner of the current repository
const owner = process.env.GITHUB_REPOSITORY.split('/')[0];
core.debug(`Owner: ${owner}`);
// get repository list for this owner
const result = await request(`GET /users/${owner}/repos`);
const repositories = result.data.map(repo => repo.name);
// send the event to all repositories
repositories.forEach(repository => {
core.info(`Send event to repository: ${repository}`);
request(
`POST /repos/${owner}/${repository}/dispatches`,
{
headers: {
authorization: `token ${token}`
},
mediaType: {
previews: ['everest']
},
event_type: `${eventType}`
}
);
});
} catch (error) {
core.setFailed(error.message);
}
}
run();