From 600097c9765c8c582baae4561af854d8217b50b4 Mon Sep 17 00:00:00 2001 From: William Harrison Date: Mon, 6 Mar 2023 06:59:14 +0800 Subject: [PATCH 01/10] Create raw-api.yml --- .github/workflows/raw-api.yml | 46 +++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 .github/workflows/raw-api.yml diff --git a/.github/workflows/raw-api.yml b/.github/workflows/raw-api.yml new file mode 100644 index 0000000..b20c81f --- /dev/null +++ b/.github/workflows/raw-api.yml @@ -0,0 +1,46 @@ +name: Raw API + +on: + push: + branches: [main] + paths: + - "domains/*" + - ".github/workflows/raw-api.yml" + - "scripts/raw-api.js" + +jobs: + update: + name: Update + runs-on: ubuntu-latest + + steps: + - name: Checkout + uses: actions/checkout@v2 + + - name: Setup Node + uses: actions/setup-node@v2 + with: + node-version: 16 + + - run: mkdir raw-api + + - name: Create CNAME + run: echo "raw.freesubdomains.org" > ./raw-api/CNAME + + - name: Create index.json + run: echo "" > ./raw-api/index.json + + - name: Run Script + run: node scripts/raw-api.js + + - name: Push + uses: cpina/github-action-push-to-another-repository@main + with: + source-directory: "raw-api" + destination-github-username: is-a-good-dev + destination-repository-name: raw-api + user-email: bot@is-a-good.dev + user-name: is-a-good-dev-BOT + commit-message: "Update Data via is-a-good-dev/register" + env: + API_TOKEN_GITHUB: ${{ secrets.BOT_PAT_TOKEN }} From fd092fe6fa4ade447b5150300ba0ae0927aa488a Mon Sep 17 00:00:00 2001 From: William Harrison Date: Mon, 6 Mar 2023 07:03:51 +0800 Subject: [PATCH 02/10] Create raw-api.js --- scripts/raw-api.js | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 scripts/raw-api.js diff --git a/scripts/raw-api.js b/scripts/raw-api.js new file mode 100644 index 0000000..77c9b6b --- /dev/null +++ b/scripts/raw-api.js @@ -0,0 +1,45 @@ +const fs = require("fs"); +const path = require("path"); + +const directoryPath = path.join(__dirname, "../sub-logs"); + +let combinedArray = []; + +fs.readdir(directoryPath, function (err, files) { + if(err) throw err; + + function removeValue(value, index, arr) { + if(value === "reserved") { + arr.splice(index, 1); + return true; + } + + return false; + } + + files.filter(removeValue); + + files.forEach(function (file) { + const filePath = path.join(directoryPath, file); + + fs.readFile(filePath, "utf8", (err, data) => { + if(err) throw err; + + const dataArray = [JSON.parse(data)]; + + for(const item of dataArray) { + delete item.owner.email; + + item.domain = path.parse(file).name + ".is-a-good.dev"; + } + + combinedArray = combinedArray.concat(dataArray); + + if(combinedArray.length === files.length) { + fs.writeFile("raw-api/index.json", JSON.stringify(combinedArray), (err) => { + if(err) throw err; + }) + } + }) + }) +}) From fcdeec1733a74ba7c2e50907ed864baa21045e6f Mon Sep 17 00:00:00 2001 From: William Harrison Date: Mon, 6 Mar 2023 07:04:58 +0800 Subject: [PATCH 03/10] Create raw.json --- sub-logs/reserved/raw.json | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 sub-logs/reserved/raw.json diff --git a/sub-logs/reserved/raw.json b/sub-logs/reserved/raw.json new file mode 100644 index 0000000..10f5494 --- /dev/null +++ b/sub-logs/reserved/raw.json @@ -0,0 +1,15 @@ +{ + "owner": { + "username": "wclarkey", + "email": "will@is-a-good.dev" + }, + + "target": { + "CNAME": { + "name": "raw", + "value": "is-a-good-dev.github.io" + } + }, + + "proxied": false +} From 2dfc7c63691c9a29788059165b1b9bfc69be2094 Mon Sep 17 00:00:00 2001 From: William Harrison Date: Mon, 6 Mar 2023 11:40:59 +0800 Subject: [PATCH 04/10] Update raw-api.yml --- .github/workflows/raw-api.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/raw-api.yml b/.github/workflows/raw-api.yml index b20c81f..7ba03f8 100644 --- a/.github/workflows/raw-api.yml +++ b/.github/workflows/raw-api.yml @@ -39,7 +39,7 @@ jobs: source-directory: "raw-api" destination-github-username: is-a-good-dev destination-repository-name: raw-api - user-email: bot@is-a-good.dev + user-email: will@is-a-good.dev user-name: is-a-good-dev-BOT commit-message: "Update Data via is-a-good-dev/register" env: From afb49082bb6cbfe1e7cae70076c44628c1ec6f2f Mon Sep 17 00:00:00 2001 From: William Harrison Date: Tue, 14 Mar 2023 09:29:27 +0800 Subject: [PATCH 05/10] Update raw-api.yml --- .github/workflows/raw-api.yml | 30 ++++++++---------------------- 1 file changed, 8 insertions(+), 22 deletions(-) diff --git a/.github/workflows/raw-api.yml b/.github/workflows/raw-api.yml index 7ba03f8..4e178ed 100644 --- a/.github/workflows/raw-api.yml +++ b/.github/workflows/raw-api.yml @@ -15,32 +15,18 @@ jobs: steps: - name: Checkout - uses: actions/checkout@v2 + uses: actions/checkout@v3 - name: Setup Node uses: actions/setup-node@v2 with: node-version: 16 - - run: mkdir raw-api - - - name: Create CNAME - run: echo "raw.freesubdomains.org" > ./raw-api/CNAME - - - name: Create index.json - run: echo "" > ./raw-api/index.json - - name: Run Script - run: node scripts/raw-api.js - - - name: Push - uses: cpina/github-action-push-to-another-repository@main - with: - source-directory: "raw-api" - destination-github-username: is-a-good-dev - destination-repository-name: raw-api - user-email: will@is-a-good.dev - user-name: is-a-good-dev-BOT - commit-message: "Update Data via is-a-good-dev/register" - env: - API_TOKEN_GITHUB: ${{ secrets.BOT_PAT_TOKEN }} + run: | + git config --global user.email "will@is-a,good.dev" + git config --global user.name "is-a-good-dev-BOT" + node scripts/raw-api.js + git add util/index.json + git commit -m "Update Raw API" + git push From 33909ec5de62b948769294be8526239421e20fd1 Mon Sep 17 00:00:00 2001 From: William Harrison Date: Tue, 14 Mar 2023 09:31:18 +0800 Subject: [PATCH 06/10] Update raw-api.js --- scripts/raw-api.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/raw-api.js b/scripts/raw-api.js index 77c9b6b..464747f 100644 --- a/scripts/raw-api.js +++ b/scripts/raw-api.js @@ -36,7 +36,7 @@ fs.readdir(directoryPath, function (err, files) { combinedArray = combinedArray.concat(dataArray); if(combinedArray.length === files.length) { - fs.writeFile("raw-api/index.json", JSON.stringify(combinedArray), (err) => { + fs.writeFile("utils/raw.json", JSON.stringify(combinedArray), (err) => { if(err) throw err; }) } From d8c6c3cdc471967d688eb273147bfe3e60faf583 Mon Sep 17 00:00:00 2001 From: William Harrison Date: Tue, 14 Mar 2023 09:33:04 +0800 Subject: [PATCH 07/10] Update raw-api.yml --- .github/workflows/raw-api.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/raw-api.yml b/.github/workflows/raw-api.yml index 4e178ed..79396fe 100644 --- a/.github/workflows/raw-api.yml +++ b/.github/workflows/raw-api.yml @@ -27,6 +27,6 @@ jobs: git config --global user.email "will@is-a,good.dev" git config --global user.name "is-a-good-dev-BOT" node scripts/raw-api.js - git add util/index.json + git add utils/raw.json git commit -m "Update Raw API" git push From d72a91368a9b7ad4a00f99ce5611fff723767706 Mon Sep 17 00:00:00 2001 From: William Harrison Date: Tue, 14 Mar 2023 09:34:07 +0800 Subject: [PATCH 08/10] Delete raw.json --- sub-logs/reserved/raw.json | 15 --------------- 1 file changed, 15 deletions(-) delete mode 100644 sub-logs/reserved/raw.json diff --git a/sub-logs/reserved/raw.json b/sub-logs/reserved/raw.json deleted file mode 100644 index 10f5494..0000000 --- a/sub-logs/reserved/raw.json +++ /dev/null @@ -1,15 +0,0 @@ -{ - "owner": { - "username": "wclarkey", - "email": "will@is-a-good.dev" - }, - - "target": { - "CNAME": { - "name": "raw", - "value": "is-a-good-dev.github.io" - } - }, - - "proxied": false -} From b1b12ee3189100fd2d5c75551b9824a82dfe723b Mon Sep 17 00:00:00 2001 From: William Harrison Date: Tue, 14 Mar 2023 09:34:54 +0800 Subject: [PATCH 09/10] Create raw.json --- utils/raw.json | 1 + 1 file changed, 1 insertion(+) create mode 100644 utils/raw.json diff --git a/utils/raw.json b/utils/raw.json new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/utils/raw.json @@ -0,0 +1 @@ + From d047a2c08dd2f429f2008b4db70654a09718ee40 Mon Sep 17 00:00:00 2001 From: Tweak Date: Mon, 13 Mar 2023 19:46:07 -0600 Subject: [PATCH 10/10] Update raw-api.yml Fix email --- .github/workflows/raw-api.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/raw-api.yml b/.github/workflows/raw-api.yml index 79396fe..e65c71c 100644 --- a/.github/workflows/raw-api.yml +++ b/.github/workflows/raw-api.yml @@ -24,7 +24,7 @@ jobs: - name: Run Script run: | - git config --global user.email "will@is-a,good.dev" + git config --global user.email "will@is-a-good.dev" git config --global user.name "is-a-good-dev-BOT" node scripts/raw-api.js git add utils/raw.json