mirror of
https://github.com/BradNut/awesome-uses
synced 2025-09-08 17:40:31 +00:00
ci: delete old data-validate step
This commit is contained in:
parent
bc624f1517
commit
afced1a6b7
3 changed files with 1 additions and 63 deletions
5
.github/workflows/data-validate.yml
vendored
5
.github/workflows/data-validate.yml
vendored
|
|
@ -25,11 +25,6 @@ jobs:
|
|||
- name: Install Dependencies
|
||||
run: npm install
|
||||
|
||||
- name: Validate data.js
|
||||
run: node ./scripts/data-validate.js
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
- name: Validate data.js using DangerJS
|
||||
run: npx danger ci
|
||||
env:
|
||||
|
|
|
|||
|
|
@ -1,10 +1,5 @@
|
|||
const core = require('@actions/core');
|
||||
const {
|
||||
getMasterData,
|
||||
Schema,
|
||||
getStatusCode,
|
||||
communicateValidationOutcome,
|
||||
} = require('./utils.js');
|
||||
const { getMasterData, Schema, getStatusCode } = require('./utils.js');
|
||||
const srcData = require('../src/data.js');
|
||||
|
||||
async function main() {
|
||||
|
|
@ -37,8 +32,6 @@ async function main() {
|
|||
}
|
||||
}
|
||||
|
||||
await communicateValidationOutcome(errors, failedUrls, data);
|
||||
|
||||
return {
|
||||
failedUrls,
|
||||
errors,
|
||||
|
|
@ -46,8 +39,4 @@ async function main() {
|
|||
};
|
||||
}
|
||||
|
||||
if (require.main === module) {
|
||||
main();
|
||||
}
|
||||
|
||||
module.exports = main;
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
const exec = require('@actions/exec');
|
||||
const core = require('@actions/core');
|
||||
const github = require('@actions/github');
|
||||
const Joi = require('@hapi/joi');
|
||||
const http = require('http');
|
||||
const https = require('https');
|
||||
|
|
@ -85,48 +84,3 @@ module.exports.getStatusCode = function(url) {
|
|||
.on('error', err => reject(err));
|
||||
});
|
||||
};
|
||||
|
||||
// If there are errors, will fail the action & add a comment detailing the issues
|
||||
// If there are no errors, will leave an "all-clear" comment with relevant URLs (to ease a potential manual check)
|
||||
module.exports.communicateValidationOutcome = async function(
|
||||
errors,
|
||||
failedUrls,
|
||||
changedData
|
||||
) {
|
||||
let comment = '';
|
||||
if (errors.length || failedUrls.length) {
|
||||
core.setFailed('Action failed with errors, see logs & comment');
|
||||
|
||||
comment += [
|
||||
'🚨 We have detected the following issues, let us (contributors) know if you need support or clarifications:',
|
||||
...errors.map(e => `- ${e.message}`),
|
||||
...failedUrls.map(url => `- URL is invalid: ${url}`),
|
||||
].join('\n');
|
||||
} else {
|
||||
comment += [
|
||||
'✅ Automatic validation checks succeeded for:',
|
||||
// Comment with the URLs of users that have changed
|
||||
// for easy access, way easier than taking a screenshot
|
||||
...changedData.map(({ name, url }) => `- ${name}, ${url}`),
|
||||
].join('\n');
|
||||
}
|
||||
|
||||
const { GITHUB_TOKEN } = process.env;
|
||||
const { context } = github;
|
||||
if (!GITHUB_TOKEN || !context.payload.pull_request) {
|
||||
core.error(
|
||||
'Cannot add a comment if GITHUB_TOKEN or context.payload.pull_request is not set'
|
||||
);
|
||||
core.info(`Comment contents:\n${comment}`);
|
||||
return;
|
||||
}
|
||||
|
||||
const pullRequestNumber = context.payload.pull_request.number;
|
||||
|
||||
const octokit = new github.GitHub(GITHUB_TOKEN);
|
||||
await octokit.issues.createComment({
|
||||
...context.repo,
|
||||
issue_number: pullRequestNumber,
|
||||
body: comment,
|
||||
});
|
||||
};
|
||||
|
|
|
|||
Loading…
Reference in a new issue