-
Notifications
You must be signed in to change notification settings - Fork 4
/
index.js
34 lines (28 loc) · 1.33 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
const core = require('@actions/core');
const util = require('./util');
const GoCD = require('./util/gocd');
const GoCDServerUrl = core.getInput('GOCD_SERVER_URL', {required: true});
const GoCDAdminUserAccessToken = core.getInput('GOCD_ADMIN_ACCESS_TOKEN', {required: true});
const GoCDConfigRepositoryId = core.getInput('GOCD_CONFIG_REPOSITORY_ID', {required: true});
(async function () {
try {
console.log(`Fetching '${GoCDConfigRepositoryId}' config repository...`);
const repo = await GoCD.fetchConfigRepository(GoCDServerUrl, GoCDAdminUserAccessToken, GoCDConfigRepositoryId);
const matchingFilePaths = util.findGoCDConfigFilesForPlugin(repo.plugin_id);
if (matchingFilePaths.length === 0) {
[
'',
`No GoCD config files found in the repository for '${repo.plugin_id}' plugin!`,
`Skipping validations...`
].forEach((line) => console.log("\x1b[33m", line));
return;
}
console.log("\nSending following files for config merge validations:");
matchingFilePaths.forEach(p => console.log(`- ${p}`));
console.log("\nPerforming preflight check...");
const result = await GoCD.preflight(GoCDServerUrl, GoCDAdminUserAccessToken, repo.id, repo.plugin_id, matchingFilePaths);
util.representResult(result);
} catch (e) {
core.setFailed(`\n${e.message}`)
}
})();