mirror of
https://github.com/tiennm99/is-a-dev.git
synced 2026-08-07 18:23:11 +00:00
Merge branch 'main' into main
This commit is contained in:
@@ -17,10 +17,3 @@ jobs:
|
||||
uses: borales/actions-yarn@v2.0.0
|
||||
with:
|
||||
cmd: test
|
||||
#label:
|
||||
#runs-on: ubuntu-latest
|
||||
#steps:
|
||||
#- name: Labelling pull request
|
||||
#uses: actions/labeler@main
|
||||
#with:
|
||||
#repo-token: "${{ secrets.GITHUB_TOKEN }}"
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
name: Label
|
||||
on:
|
||||
schedule:
|
||||
- cron: "0 * * * *"
|
||||
|
||||
jobs:
|
||||
label:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Labelling pull request
|
||||
uses: actions/labeler@main
|
||||
with:
|
||||
repo-token: "${{ secrets.GITHUB_TOKEN }}"
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
{ nixpkgs ? import <nixpkgs> {} }:
|
||||
let
|
||||
inherit (nixpkgs) pkgs;
|
||||
|
||||
nixPackages = with pkgs; [
|
||||
nodejs-15_x
|
||||
yarn
|
||||
dnsutils
|
||||
certbot
|
||||
];
|
||||
in pkgs.stdenv.mkDerivation {
|
||||
name = "env";
|
||||
buildInputs = nixPackages;
|
||||
}
|
||||
+2
-2
@@ -4,9 +4,9 @@
|
||||
"owner": {
|
||||
"username": "WilloIzCitron",
|
||||
"email": "",
|
||||
"twitter": "tegasaziz"
|
||||
"twitter": "willoizcitron"
|
||||
},
|
||||
"record": {
|
||||
"CNAME": "willoizcitron.github.io"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Executable
+100
@@ -0,0 +1,100 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
export 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 \
|
||||
-m 'phenax5@gmail.com' \
|
||||
-d '*.is-a.dev,is-a.dev' \
|
||||
$(if_dry_run "--dry-run" "");
|
||||
|
||||
echo "+-----------------------------------------------+";
|
||||
echo "| Certificates output to: |";
|
||||
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"};
|
||||
echo "
|
||||
const { domainService } = require('./utils/domain-service');
|
||||
const { ENV, DOMAIN_DOMAIN } = require('./utils/constants');
|
||||
const record = {
|
||||
name: '$name',
|
||||
type: '$type',
|
||||
address: '$address',
|
||||
ttl: $ttl,
|
||||
};
|
||||
console.log('Uploading $name to', DOMAIN_DOMAIN, '(', ENV, ')...');
|
||||
domainService.$method(record)()
|
||||
.then(d => console.log(d.cpanelresult ? d.cpanelresult.data : d))
|
||||
.catch(console.error);
|
||||
" | node -
|
||||
}
|
||||
|
||||
update_acme_txt_record() {
|
||||
update_record add TXT '_acme-challenge' "$1";
|
||||
}
|
||||
|
||||
update_www_record() {
|
||||
update_record remove CNAME 'www' "is-a-dev.github.io";
|
||||
sleep 1;
|
||||
update_record add A 'www' "68.65.123.44";
|
||||
}
|
||||
|
||||
upload_acme_file() {
|
||||
local key="$1";
|
||||
local value="$2";
|
||||
echo "
|
||||
const { cpanel } = require('./utils/lib/cpanel');
|
||||
const { ENV, DOMAIN_DOMAIN, DOMAIN_USER } = require('./utils/constants');
|
||||
|
||||
const file = {
|
||||
dir: '/home/' + DOMAIN_USER + '/public_html/.well-known/acme-challenge',
|
||||
file: '$key',
|
||||
content: '$value',
|
||||
};
|
||||
|
||||
console.log('Uploading acme validation file to', DOMAIN_DOMAIN, '(', ENV, ')...');
|
||||
cpanel.file.write(file).then(console.log).catch(console.error);
|
||||
" | node -;
|
||||
}
|
||||
|
||||
reset_acme() {
|
||||
update_record remove A 'www.is-a.dev' "68.65.123.44";
|
||||
sleep 1;
|
||||
update_record add CNAME 'www.is-a.dev' "is-a-dev.github.io";
|
||||
}
|
||||
|
||||
case "$1" in
|
||||
check)
|
||||
echo "TXT record:: $(dig +noall +answer _acme-challenge.is-a.dev TXT | awk '{print $5}')";
|
||||
;;
|
||||
acme_txt) update_acme_txt_record "$2" ;;
|
||||
acme_file) upload_acme_file "$2" "$3" ;;
|
||||
cert) generate_certificate ;;
|
||||
reset) reset_acme ;;
|
||||
*) echo "Invalid command"; exit 1; ;;
|
||||
esac
|
||||
|
||||
|
||||
### STEPS ###
|
||||
# Run ./scripts/certbot.sh cert
|
||||
# Run ./scripts/certbot.sh acme_txt "<key>"
|
||||
# Run ./scripts/certbot.sh acme_file "<key>" "<value>"
|
||||
# Upload cert.pem and privkey.pem contents to SSL > Manage SSL Sites
|
||||
# Run ./scripts/certbot.sh reset
|
||||
|
||||
@@ -18,6 +18,7 @@ const recordToZone = ({ name, type, address, id }) => ({
|
||||
type,
|
||||
address,
|
||||
...(type === 'CNAME' ? { cname: address } : {}),
|
||||
...(type === 'TXT' ? { txtdata: address } : {}),
|
||||
});
|
||||
|
||||
const cleanName = name => name === DOMAIN_DOMAIN ? '@' : `${name}`.replace(new RegExp(`\\.${DOMAIN_DOMAIN}\\.?$`), '').toLowerCase();
|
||||
@@ -114,7 +115,7 @@ const getDomainService = ({ cpanel }) => {
|
||||
return { added: add.length, removed: remove.length };
|
||||
};
|
||||
|
||||
return { getHosts, updateHosts };
|
||||
return { getHosts, addZoneRecord, removeZoneRecord, updateHosts };
|
||||
};
|
||||
|
||||
const domainService = getDomainService({ cpanel });
|
||||
|
||||
@@ -64,6 +64,9 @@ const CpanelClient = (options) => {
|
||||
// -> {}
|
||||
remove: uapi('Mime', 'delete_redirect'),
|
||||
},
|
||||
file: {
|
||||
write: uapi('Fileman', 'save_file_content', { from_charset: 'UTF-8', to_charset: 'UTF-8', fallback: 1 }),
|
||||
},
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user