mirror of
https://github.com/tiennm99/is-a-good-dev.git
synced 2026-10-14 12:16:52 +00:00
Merge pull request #309 from is-a-good-dev/WilliamDavidHarrison-patch-1
Clean up CI code
This commit is contained in:
2 files changed
+16
-10
No files matched your search
@@ -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
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user