generated from DayDreamMods/action-template
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
37 lines (30 loc) · 1.23 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
const core = require('@actions/core');
const github = require('@actions/github');
(async() => {
const octokit = github.getOctokit(core.getInput('token'));
const sourceRepo = core.getInput('source-repo');
let destRepo = core.getInput("dest-repo");
if (destRepo.length == 0)
destRepo = github.context.payload.repository.full_name;
const settings = core.getInput('settings');
const [sourceOwner, sourceRepoName] = sourceRepo.split('/');
const [destOwner, destRepoName] = destRepo.split('/');
const sourceRequest = await octokit.rest.repos.get({
owner: sourceOwner, repo: sourceRepoName
});
if (sourceRequest.status != 200)
throw new Exception('Bad API response: ' + sourceRequest.status);
console.log("Obtained request data: \n" + JSON.stringify(sourceRequest.data));
const refinedSettings = {};
for (const setting of settings.split('\n')) {
if (setting.length == 0) continue;
const elem = sourceRequest.data[setting];
if (elem == null) continue;
refinedSettings[setting] = elem;
}
console.log(refinedSettings);
await octokit.rest.repos.update({
owner: destOwner, repo: destRepoName,
...refinedSettings
});
})();