Skip to content

Commit

Permalink
initial
Browse files Browse the repository at this point in the history
  • Loading branch information
SX-9 committed Oct 14, 2024
1 parent f5c9916 commit aa73cbf
Show file tree
Hide file tree
Showing 8 changed files with 214 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .github/CODEOWNERS
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
* @SX-9
/domains/ @partofmyid/maintainers
14 changes: 14 additions & 0 deletions .github/workflows/check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
name: Check

on: pull_request

jobs:
check:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: DNSControl check
uses: koenrh/dnscontrol-action@v3
with:
args: check
config_file: 'dnsconfig.js'
29 changes: 29 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: Publish

on:
workflow_dispatch:
push:
branches: [main]
paths:
- "domains/**"
- ".github/workflows/publish.yml"
- "dnsconfig.js"

concurrency:
group: ${{ github.ref }}-publish
cancel-in-progress: false

jobs:
dns:
name: DNS
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- run: echo '{"cloudflare":{"TYPE":"CLOUDFLAREAPI","apitoken":"$CLOUDFLARE_API_TOKEN"}}' > ./creds.json
- name: Publish
uses: is-cool-me/[email protected]
env:
CLOUDFLARE_API_TOKEN: ${{ secrets.CF_API_TOKEN }}
with:
args: push
config_file: "dnsconfig.js"
38 changes: 38 additions & 0 deletions .github/workflows/validation.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: Validation

on:
workflow_dispatch:
pull_request:
push:
branches: [main]
paths:
- "domains/**"
- ".github/workflows/validation.yml"
- "dnsconfig.js"

concurrency:
group: ${{ github.ref }}-validation
cancel-in-progress: true

jobs:
dns:
name: DNS
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Check
uses: koenrh/dnscontrol-action@v3
with:
args: check
config_file: "dnsconfig.js"
json:
name: JSON
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: JSON Syntax Check
uses: limitusus/json-syntax-check@v2
with:
pattern: "\\.json$"
env:
BASE: "domains/"
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
creds.json
types-dnscontrol.d.ts
5 changes: 5 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"cSpell.words": [
"dnscontrol"
]
}
116 changes: 116 additions & 0 deletions dnsconfig.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
// @ts-check
/// <reference path="types-dnscontrol.d.ts" />
// ^^^^^^ https://docs.dnscontrol.org/getting-started/typescript
var regNone = NewRegistrar("none");
var providerCf = DnsProvider(NewDnsProvider("cloudflare", "", {
// manage_redirects: true,
}));

var rootDomain = 'part-of.my.id';
var registerSite = 'register-site.pages.dev';
var proxy = {
on: { "cloudflare_proxy": "on" },
off: { "cloudflare_proxy": "off" }
}

function getDomainsList(filesPath) {
// @ts-expect-error
var files = glob.apply(null, [filesPath, true, '.json']);
var result = [];

for (var i = 0; i < files.length; i++) {
var basename = files[i].split('/').reverse()[0];
var name = basename.split('.')[0];
result.push({ name: name, data: require(files[i]) });
}
return result;
}

var domains = getDomainsList('./domains');
var commits = [];

for (var idx in domains) {
var domainData = domains[idx].data;
var subdomain = domains[idx].name;
var proxyState = proxy.on;
if (domainData.proxied === false) proxyState = proxy.off;

if ('A' in domainData.record) {
for (var a in domainData.record.A) {
commits.push(
A(subdomain, IP(domainData.record.A[a]), proxyState)
);
}
}

if ('AAAA' in domainData.record) {
for (var aaaa in domainData.record.AAAA) {
commits.push(
AAAA(subdomain, domainData.record.AAAA[aaaa], proxyState)
);
}
}

if ('CNAME' in domainData.record) {
commits.push(
CNAME(subdomain, domainData.record.CNAME + ".", proxyState)
);
}

if ('MX' in domainData.record) {
for (var mx in domainData.record.MX) {
commits.push(
MX(subdomain, 10, domainData.record.MX[mx] + ".")
);
}
}

// if ('NS' in domainData.record) {
// for (var ns in domainData.record.NS) {
// commits.push(
// NS(subdomain, domainData.record.NS[ns] + ".")
// );
// }
// }

if ('TXT' in domainData.record) {
for (var txt in domainData.record.TXT) {
commits.push(
TXT(subdomain, domainData.record.TXT[txt])
);
}
}

// if ('CAA' in domainData.record) {
// for (var caa in domainData.record.CAA) {
// var caaRecord = domainData.record.CAA[caa];
// commits.push(
// CAA(subdomain, caaRecord.flags, caaRecord.tag, caaRecord.value)
// );
// }
// }

if ('SRV' in domainData.record) {
for (var srv in domainData.record.SRV) {
var srvRecord = domainData.record.SRV[srv];
commits.push(
SRV(subdomain, srvRecord.priority, srvRecord.weight, srvRecord.port, srvRecord.target + ".")
);
}
}

// if ('PTR' in domainData.record) {
// for (var ptr in domainData.record.PTR) {
// commits.push(
// PTR(subdomain, domainData.record.PTR[ptr] + ".")
// );
// }
// }
}

commits.push(
// CF_REDIRECT("*", "https://" + rootDomain + '/unregistered'),
ALIAS("@", registerSite + ".", proxy.on)
);

D(rootDomain, regNone, providerCf, commits);
8 changes: 8 additions & 0 deletions domains/satr14.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"owner": {
"username": "SX-9"
},
"record": {
"CNAME": "4th-site.pages.dev"
}
}

0 comments on commit aa73cbf

Please sign in to comment.