mirror of
https://github.com/BradNut/awesome-uses
synced 2025-09-08 17:40:31 +00:00
* comment on PR after validation run. * bork my url for sample output * populate GITHUB_TOKEN in action * more verbose logging * more logging * fix wrong import * logging * remove logging & implementation attempt * log out comment creation query output * styling * prettify comments + increase logging * more prettifying of the text * Revert "bork my url for sample output" This reverts commit 0c6d17450e753cd407db69a8129bf0cbc5831b88. * add data change to trigger GH action * improve messages... * change my URL so it appears in the message * more formatting of comments * move + rename commentPullRequest -> utils.communicateValationOutcome
43 lines
1.1 KiB
JavaScript
43 lines
1.1 KiB
JavaScript
const core = require('@actions/core');
|
|
const {
|
|
getMasterData,
|
|
Schema,
|
|
getStatusCode,
|
|
communicateValidationOutcome,
|
|
} = require('./utils.js');
|
|
const srcData = require('../src/data.js');
|
|
|
|
async function main() {
|
|
// on master branch will be empty array
|
|
const masterDataUrls = (await getMasterData()).map(d => d.url);
|
|
// so here data will be an array with all users
|
|
const data = srcData.filter(d => !masterDataUrls.includes(d.url));
|
|
|
|
const errors = data
|
|
.map(person => Schema.validate(person))
|
|
.filter(v => v.error)
|
|
.map(v => v.error);
|
|
|
|
errors.forEach(e => {
|
|
core.error(e._original.name || e._original.url);
|
|
e.details.forEach(d => core.error(d.message));
|
|
});
|
|
|
|
const failedUrls = [];
|
|
for (const { url } of data) {
|
|
try {
|
|
const statusCode = await getStatusCode(url);
|
|
if (statusCode < 200 || statusCode >= 400) {
|
|
core.error(`Ping to "${url}" failed with status: ${statusCode}`);
|
|
failedUrls.push(url);
|
|
}
|
|
} catch (e) {
|
|
core.error(`Ping to "${url}" failed with error: ${e}`);
|
|
failedUrls.push(url);
|
|
}
|
|
}
|
|
|
|
await communicateValidationOutcome(errors, failedUrls, data);
|
|
}
|
|
|
|
main();
|