-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
214 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
* @SX-9 | ||
/domains/ @partofmyid/maintainers |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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/" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
creds.json | ||
types-dnscontrol.d.ts |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"cSpell.words": [ | ||
"dnscontrol" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"owner": { | ||
"username": "SX-9" | ||
}, | ||
"record": { | ||
"CNAME": "4th-site.pages.dev" | ||
} | ||
} |