Merge branch 'is-a-good-dev:main' into main

This commit is contained in:
XYZ authored and GitHub committed 2022-12-03 21:36:11 +08:00
commit 851650911e
6 files changed
+73 -25

No files matched your search

@@ -1,7 +1,7 @@
name: Add DNS records
name: Update Records
on:
push:
branches: [ main ]
branches: [main]
jobs:
validation:
@@ -13,17 +13,17 @@ jobs:
- uses: actions/setup-node@v3
with:
node-version: 16
- name: Get changed files
- name: Get Files
id: changed-files
uses: tj-actions/changed-files@v34
with:
files: |
sub-logs/**
reserved/**
- name: Install modules
- name: Install Modules
if: steps.changed-files.outputs.any_changed == 'true'
run: yarn
- name: Add records
- name: Publish Records
if: steps.changed-files.outputs.any_changed == 'true'
id: tests
run: yarn add-records
+12 -15
View File
@@ -8,41 +8,38 @@ jobs:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Get changed files
- name: Get Files
id: changed-files
uses: tj-actions/changed-files@v34
with:
files: |
sub-logs/**
reserved/**
- name: Install modules
- name: Install Modules
if: steps.changed-files.outputs.any_changed == 'true'
run: yarn
- name: Run tests
- name: Run Tests
if: steps.changed-files.outputs.any_changed == 'true'
id: tests
run: yarn test
env:
FILES: ${{ steps.changed-files.outputs.all_changed_files }}
actions_path: ${{ github.workspace }}
- name: Post message
- name: Comment
if: steps.tests.outputs.shouldComment == 'true'
uses: mshick/add-pr-comment@v1
with:
message: |
**Validation Results**
- Information Validation
${{steps.tests.outputs.infoMessage}}
${{steps.tests.outputs.infoReason}}
- DNS Record Validation
${{steps.tests.outputs.recordMessage}}
${{steps.tests.outputs.recordInfo}}
- JSON File Content
message: |
## Validation Results
| Information Validation | Record Validation |
|-|-|
| ${{steps.tests.outputs.infoMessage}} ${{steps.tests.outputs.infoReason}} | ${{steps.tests.outputs.recordMessage}} ${{steps.tests.outputs.recordInfo}} |
### JSON File Content
```json
${{steps.tests.outputs.jsonData}}
```
repo-token: ${{ secrets.GITHUB_TOKEN }}
proxy-url: https://api.is-a-good.dev/github-proxy/
repo-token-user-login: 'github-actions[bot]' # The user.login for temporary GitHub tokens
allow-repeats: false # This is the default
allow-repeats: false # Default: false
+22
View File
@@ -0,0 +1,22 @@
{
"repo": "https://github.com/uzukidev/avalynndev",
"owner": {
"username": "avalynndev",
"email": "avalynndev@gmail.com"
},
"target": {
"CNAME": {
"name": "avalynn",
"value": "cname.vercel-dns.com"
},
"TXT": {
"name": "_vercel",
"value": "vc-domain-verify=avalynn.is-a-good.dev,3a44282059a77b85f618"
}
},
"proxied": false
}
+18
View File
@@ -0,0 +1,18 @@
{
"repo": "https://github.com/surajaswal-dev/surajaswal",
"owner": {
"username": "surajaswal-dev",
"email": "surajaswal29@gmail.com"
},
"target": {
"CNAME": {
"name": "surajaswal",
"value": "surajaswal-dev.github.io"
}
},
"proxied": false
}
+14 -3
View File
@@ -3,25 +3,36 @@ const getJSON = require('../utils/getJSON.js');
const checkInfo = require('../utils/checkInfo.js');
const checkRecords = require('../utils/checkRecords.js');
const data = getJSON(process.env.FILES);
if (data == 3) {
core.setOutput('infoMessage', "Could not validate info.");
core.setOutput('recordMessage', "Could not validate records.");
core.setOutput('jsonData', "Could not read the JSON file, did you have an error in your syntax?")
core.setOutput('shouldComment', 'true')
}
if (data == false) {
core.setOutput('shouldComment', 'false')
console.log('Not a subdomain file')
process.exit(0)
}
core.setOutput('infoMessage', "Could not validate info.");
core.setOutput('recordMessage', "Could not validate records.");
core.setOutput('jsonData', data)
core.setOutput('shouldComment', 'true')
test('check if json file has required info', async () => {
const passed = await checkInfo(data);
let infoMessage = passed === true ? "Valid Info Provided." : passed === "unknown" ? "Error Verifying Email.\nA maintainer will have to manually verify your email.\nReason:" : "Invalid Info Provided.\nPlease check your provided info.\nReason:";
let infoMessage = passed === true ? "Valid information provided." : passed === "unknown" ? "Error verifying email address.\nA maintainer will have to manually verify your email address.\nReason:" : "Invalid information provided.\nPlease check your provided information.\nReason:";
core.setOutput('infoMessage', infoMessage);
expect(passed).toBeTruthy();
}, 15000);
test('check if json file follows format', () => {
test('Check if JSON file follows format', () => {
const passed = checkRecords(data);
let recordMessage = passed === true ? "Valid Records Provided." : "Invalid Records Provided.\nPlease check your provided records.\nThey should only be of type `CNAME` or `A` or `TXT`, and should follow their respective formats.";
let recordMessage = passed === true ? "Valid records provided." : "Invalid records provided.\nPlease check your provided records.\nThey should only be of type `A`, `CNAME` or `TXT`, and should follow their respective formats.";
core.setOutput('recordMessage', recordMessage);
expect(passed).toBe(true);
});
+2 -2
View File
@@ -16,12 +16,12 @@ function getJSON(file, filename) {
return data; // Return true or false, depending if tests pass or fail.
}
return false; // It doesn't exist
return 3; // It doesn't exist
} catch(err) {
console.error(err);
}
return false;
return 3;
}
module.exports = getJSON;