From d3c6ec4de9727a56b244ab34a6731fe3e7d3b73e Mon Sep 17 00:00:00 2001
From: SX-9 <90962949+SX-9@users.noreply.github.com>
Date: Wed, 12 Feb 2025 09:53:58 +0700
Subject: [PATCH] database sync
---
.github/PULL_REQUEST_TEMPLATE.md | 9 ++++--
.github/workflows/db.yml | 55 ++++++++++++++++++++++++++++++++
dbgen.js | 10 ++++++
dnsconfig.js | 3 +-
4 files changed, 73 insertions(+), 4 deletions(-)
create mode 100644 .github/workflows/db.yml
create mode 100644 dbgen.js
diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md
index ae67d6b..272300c 100644
--- a/.github/PULL_REQUEST_TEMPLATE.md
+++ b/.github/PULL_REQUEST_TEMPLATE.md
@@ -1,12 +1,15 @@
-
+
## Requirements
- [ ] The website is reachable.
- [ ] You have completed your website.
-- [ ] The CNAME record doesn't contain `https://` or `/`.
-- [ ] There is sufficient information at the `owner` field. (including `username`)
+- [ ] The CNAME record is a valid hostname and doesn't contain `https://` or `/`.
+- [ ] There is sufficient information at the `owner` field. (including your github `username`)
- [ ] I have read the [README](https://github.com/partofmyid/register) for announcements in case of any updates.
- [ ] I know what im doing and everything is ready.
diff --git a/.github/workflows/db.yml b/.github/workflows/db.yml
new file mode 100644
index 0000000..6718f8e
--- /dev/null
+++ b/.github/workflows/db.yml
@@ -0,0 +1,55 @@
+name: Database Sync
+
+on:
+ workflow_dispatch:
+ push:
+ branches: [main]
+ paths:
+ - "domains/**"
+
+jobs:
+ generate:
+ runs-on: ubuntu-latest
+ steps:
+ - name: Checkout repository
+ uses: actions/checkout@v2
+
+ - name: Set up Node.js
+ uses: actions/setup-node@v2
+ with:
+ node-version: '14'
+
+ - name: Install dependencies
+ run: npm install
+
+ - name: Generate database
+ run: node dbgen.js > database.json
+
+ - name: Upload database artifact
+ uses: actions/upload-artifact@v2
+ with:
+ name: database
+ path: database.json
+
+ upload:
+ needs: generate
+ runs-on: ubuntu-latest
+ steps:
+ - name: Checkout repository
+ uses: actions/checkout@v2
+
+ - name: Download database artifact
+ uses: actions/download-artifact@v2
+ with:
+ name: database
+ path: database.json
+
+ - name: Commit and push database.json
+ run: |
+ git config --global user.name 'github-actions'
+ git config --global user.email 'github-actions@github.com'
+ git add database.json
+ git commit -m 'Update database.json'
+ git push
+ env:
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
\ No newline at end of file
diff --git a/dbgen.js b/dbgen.js
new file mode 100644
index 0000000..afd11dd
--- /dev/null
+++ b/dbgen.js
@@ -0,0 +1,10 @@
+console.log(
+ JSON.stringify(
+ require('fs').readdirSync('./domains').map(f =>
+ [
+ f.split('.').slice(0, -1).join('.'), // subdomain
+ require(`./domains/${f}`).owner.username // owner
+ ]
+ )
+ )
+);
\ No newline at end of file
diff --git a/dnsconfig.js b/dnsconfig.js
index 6586b12..1245c58 100644
--- a/dnsconfig.js
+++ b/dnsconfig.js
@@ -1,6 +1,7 @@
// @ts-check
-///
+///
// ^^^^^^ https://docs.dnscontrol.org/getting-started/typescript
+
var regNone = NewRegistrar("none");
var providerCf = DnsProvider(NewDnsProvider("cloudflare", "CLOUDFLAREAPI", {
// manage_redirects: true,