Merge pull request #309 from is-a-good-dev/WilliamDavidHarrison-patch-1

Clean up CI code
This commit is contained in:
Tweak authored and GitHub committed 2023-01-04 14:56:40 -08:00
commit 0e96331822
2 files changed
+16 -10

No files matched your search

+5 -2
View File
@@ -2,13 +2,16 @@ const { checkIfValidIP, checkIfValidFQDN, checkInvalidDomain } = require('./uti
function checkRecords(data) {
const recordType = Object.keys(data.target)[0];
// Check if the domain is invalid
if (checkInvalidDomain(data.target[recordType].name) === true) return false;
// Check A record
if (recordType.toLowerCase() === 'a') {
return checkIfValidIP(data.target[recordType].value);
}
// Check CNAME record
if (recordType.toLowerCase() === 'cname') {
return checkIfValidFQDN(data.target[recordType].value);
}
+11 -8
View File
@@ -3,20 +3,20 @@ const fs = require('fs');
const core = require('@actions/core');
function getFiles(path) {
//get all files in path, returns arr
// Get all files in path: returns array
const allFiles = fs.readdirSync(path);
return allFiles
return allFiles;
}
function getFileExtension(filename) {
//get file ext
// Get file extension
return (/[.]/.exec(filename)) ? /[^.]+$/.exec(filename) : undefined;
}
function stripExt(filename) {
//remove file ext
return filename.substr(0, filename.lastIndexOf('.'))
// Remove file extension
return filename.substr(0, filename.lastIndexOf('.'));
}
function checkIfValidIP(str) {
@@ -34,17 +34,20 @@ function checkIfValidFQDN(str) {
}
function checkInvalidDomain(str) {
//check invalid domains
// Check invalid domains
if (invalidDomains.includes(str)) {
core.setOutput("recordInfo", "This subdomain has been blocked for register by the is-a-good.dev team.")
core.setOutput("recordInfo", "This subdomain has been blocked.")
return true;
}
//check reserved domains
// Check reserved domains
const files = getFiles("./reserved/").map(file => stripExt(file));
if (files.includes(str)) {
core.setOutput("recordInfo", "This subdomain has been reserved by the is-a-good.dev team.")
return true;
}
return false;
}