diff --git a/.github/workflows/data-validate.yml b/.github/workflows/data-validate.yml index 03e0a601..38d788bc 100644 --- a/.github/workflows/data-validate.yml +++ b/.github/workflows/data-validate.yml @@ -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: diff --git a/scripts/data-validate.js b/scripts/data-validate.js index ce588f91..b06d1732 100644 --- a/scripts/data-validate.js +++ b/scripts/data-validate.js @@ -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; diff --git a/scripts/utils.js b/scripts/utils.js index 0bbda125..fd5e7ea2 100644 --- a/scripts/utils.js +++ b/scripts/utils.js @@ -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, - }); -};