This commit is contained in:
andrewstech
2024-10-16 09:39:09 +00:00
parent c6a8883183
commit 92c44c1ad8
31 changed files with 203 additions and 2059 deletions
-8
View File
@@ -1,8 +0,0 @@
module.exports = {
hasLabel: (context, label) => {
const pr = context.payload.pull_request || context.payload.issue;
const { labels = [] } = pr;
return !!labels.find(({ name }) => name === label);
},
};
-17
View File
@@ -1,17 +0,0 @@
#!/usr/bin/env bash
echo "$PWD";
echo "AUTH ::[$CERTBOT_VALIDATION]::[$CERTBOT_TOKEN]::[$CERTBOT_REMAINING_CHALLENGES]";
echo "[$CERTBOT_DOMAIN]";
sleep 1;
./scripts/certbot.sh acme_txt "$CERTBOT_VALIDATION";
echo "Going to sleep for a few minutes...";
# TODO: Check if $CERTBOT_VALIDATION == $(./scripts/certbot.sh get-acme)?
sleep $((3*60));
./scripts/certbot.sh check;
-91
View File
@@ -1,91 +0,0 @@
#!/usr/bin/env bash
export NODE_ENV=production
DRY_RUN=0
if_dry_run() { [[ $DRY_RUN == 1 ]] && echo "$1" || echo "$2"; }
generate_certificate() {
outdir=$(mktemp -d /tmp/is-a-dev-certbot.XXXXX);
certbot \
--config-dir $outdir/config \
--work-dir $outdir/work \
--logs-dir $outdir/logs \
certonly \
--manual \
--preferred-challenges=dns \
--manual-auth-hook=./scripts/certbot-auth.sh \
-m 'phenax5@gmail.com' \
-d '*.is-a.dev,is-a.dev' \
--agree-tos \
$(if_dry_run "--dry-run" "");
echo "+-----------------------------------------------+";
echo "| Certificate output: |";
echo "|= $outdir";
echo "+-----------------------------------------------+";
}
update_record() {
local method=$([[ "$1" == "add" ]] && echo "addZoneRecord" || echo "removeZoneRecord");
local type="$2";
local name="$3";
local address="$4";
local ttl=${5:-"1"};
bun -e "
const { domainService } = require('./utils/domain-service');
const { ENV, DOMAIN_DOMAIN } = require('./utils/constants');
const method = '$method';
const name = '$name';
const type = '$type';
const record = { name, type, address: '$address', ttl: $ttl };
async function main() {
if (method === 'removeZoneRecord') {
const data = await domainService.get({ customonly: 0, name: '$name.is-a.dev.', type });
if (data.length > 0) {
record.id = data[0].line;
} else {
throw new Error('Unable to find record');
}
}
console.log('Uploading $name to', DOMAIN_DOMAIN, '(', ENV, ')...');
const data = await domainService[method](record)();
console.log(data.cpanelresult ? data.cpanelresult.data : data);
}
main().catch(console.error);
"
}
update_acme_txt_record() {
update_record add TXT '_acme-challenge' "$1";
}
reset_acme() {
sleep 1;
update_record remove TXT '_acme-challenge' '';
update_record remove TXT '_acme-challenge' '';
# update_record add CNAME 'www' "is-a-dev.github.io";
}
get_acme() { dig +noall +answer _acme-challenge.is-a.dev TXT | awk '{print $5}'; }
case "$1" in
check) echo "TXT record:: $(get_acme)" ;;
get-acme) get_acme ;;
cert) generate_certificate ;;
acme_txt) update_acme_txt_record "$2" ;;
reset) reset_acme ;;
*) echo "Invalid command"; exit 1; ;;
esac
### STEPS ###
# Run ./scripts/certbot.sh cert
# cp -r /tmp/is-a-dev-whatever /opt/app/code/is-a-dev-cert
# Upload cert.pem and privkey.pem (from config/live/is-a.dev/) contents to SSL > Manage SSL Sites
# Run ./scripts/certbot.sh reset
-76
View File
@@ -1,76 +0,0 @@
const R = require("ramda");
const {
VALID_RECORD_TYPES,
DOMAIN_HOST_IP,
TTL,
ENV,
} = require("../utils/constants");
const { domainService: dc } = require("../utils/domain-service");
const { getDomains: gd } = require("../utils/get-domain");
const getRecords = R.compose(R.toPairs, R.pick(VALID_RECORD_TYPES));
const address = (type, value) => {
if ("URL" === type) return `${value}`.replace(/\/$/g, "");
if ("TXT" === type) return value;
return (type === "CNAME" ? `${value}`.toLowerCase() : `${value}`).replace(
/[/.]$/g,
"",
);
};
const toHostList = R.chain((data) => {
// URL redirection must contain explicit A record
// Wildcard A record breaks when used with MX
// Ref: https://github.com/is-a-dev/register/issues/2365
if ((data.record.URL && data.record.MX) || data.name === "@") {
data.record.A = [DOMAIN_HOST_IP];
}
const records = getRecords(data.record);
return R.chain(([recordType, values]) => {
const valueList = Array.isArray(values) ? values : [values];
return valueList.map((value, index) => ({
name: data.name,
type: recordType,
address: address(recordType, value),
ttl: TTL,
...(recordType === "MX" ? { priority: index + 20 } : {}),
}));
}, records);
});
const registerDomains = async ({
domainService,
getDomains,
log = () => {},
}) => {
const domains = await getDomains().then(toHostList);
if (domains.length === 0)
return Promise.reject(new Error("Nothing to register"));
log(`${domains.length} records found`);
return domainService.updateHosts(domains);
};
const main = async () => {
console.log(`Running in ${ENV} mode`);
const result = await registerDomains({
domainService: dc,
getDomains: gd,
log: console.log,
});
console.log(result);
};
if (require.main === module) {
main().catch((e) => {
console.error(e);
process.exit(1);
});
} else {
module.exports = { toHostList, registerDomains };
}
-48
View File
@@ -1,48 +0,0 @@
const getInstructions = () => `
The changes have been published!! It should reflect in less than 24 hours.
## Here's what you need to do next
If your domain points to a server you own, add \`domain-name.is-a.dev\` to your server config. For https, you will have to configure ssl certificate to allow the new subdomain.
### For github pages users,
* Go to your github page repo (\`user/user.github.io\`)
* Open up the **settings** tab
* Scroll down to the **Github pages** section
* In the **Custom domain** text input, enter the domain you registered (\`domain-name.is-a.dev\`)
* Check the **Enforce HTTPS** checkbox below the input
* Give it some time to reflect and you should be good to go
## Need help with your domain?
If you are having trouble setting up your domain, [create an issue](https://github.com/is-a-dev/register/issues/new/choose). I will try my best to get back to you asap!
## Made a mistake in the record?
Don't worry, you can create a new pull request with the corrections
## Love/Hate the service?
**Love it?** Leave it a **star**! Also consider donating so that I can keep this service running forever!
**Hate it?** Please leave your feedback by [creating an issue](https://github.com/is-a-dev/register/issues/new/choose). I would really like to keep improving this service for other users.
## Wanna support this project?
Help me in my mission to keep this service alive forever by donating!
<a href="https://www.buymeacoffee.com/phenax" target="_blank"><img src="https://cdn.buymeacoffee.com/buttons/default-orange.png" alt="Buy Me A Coffee" height="28" width="119"></a> <a href="https://liberapay.com/phenax" target="_blank"><img src="https://img.shields.io/badge/liberapay-donate-yellow.svg?style=for-the-badge" alt="Liberapay recurring donation button" /></a>
`;
module.exports = {
async instructions(context, github) {
const pr = context.payload.issue || context.payload.pull_request;
const { number } = pr;
await github.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: number,
body: getInstructions(),
});
},
};
-11
View File
@@ -1,11 +0,0 @@
#!/usr/bin/env sh
sed \
-e 's/\.json.*$/.is-a.dev/g' \
-e 's/^\s*domains\///g' \
-e '/^\s*$/d' \
| while read domain; do
echo "$domain";
dig "$domain" +noall +answer && echo "done" || echo "x";
done;