diff --git a/.github/workflows/addRecords.yml b/.github/workflows/update-records.yml similarity index 84% rename from .github/workflows/addRecords.yml rename to .github/workflows/update-records.yml index 05e3bb8..7a11bb3 100644 --- a/.github/workflows/addRecords.yml +++ b/.github/workflows/update-records.yml @@ -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 diff --git a/.github/workflows/validation.yml b/.github/workflows/validation.yml index bb9a728..591f182 100644 --- a/.github/workflows/validation.yml +++ b/.github/workflows/validation.yml @@ -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 diff --git a/sub-logs/avalynn.json b/sub-logs/avalynn.json new file mode 100644 index 0000000..0c3f0ca --- /dev/null +++ b/sub-logs/avalynn.json @@ -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 +} diff --git a/sub-logs/surajaswal.json b/sub-logs/surajaswal.json new file mode 100644 index 0000000..9795717 --- /dev/null +++ b/sub-logs/surajaswal.json @@ -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 + +} diff --git a/tests/json.test.js b/tests/json.test.js index 614f73b..73e9ae4 100644 --- a/tests/json.test.js +++ b/tests/json.test.js @@ -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); }); diff --git a/utils/getJSON.js b/utils/getJSON.js index 08f971c..5b35aab 100644 --- a/utils/getJSON.js +++ b/utils/getJSON.js @@ -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;