This commit is contained in:
parent
1be978eee5
commit
e1f2c29d6b
|
@ -8,3 +8,15 @@ jobs:
|
||||||
with:
|
with:
|
||||||
node-version: "13.x"
|
node-version: "13.x"
|
||||||
- run: npm install-ci-test
|
- run: npm install-ci-test
|
||||||
|
- uses: webfactory/ssh-agent@v0.2.0
|
||||||
|
with:
|
||||||
|
ssh-private-key: ${{ secrets.SSH_PRIVATE_KEY }}
|
||||||
|
if: github.ref == 'ref/head/master'
|
||||||
|
- run: |
|
||||||
|
ssh -A root@204.48.21.111 'ssh git@github.com'
|
||||||
|
if: github.ref == 'ref/head/master'
|
||||||
|
# - run: |
|
||||||
|
# mkdir ~/.ssh
|
||||||
|
# echo "${{ secrets.SECRET_PRIVATE_DEPLOY_KEY }}" > ~/.ssh/id_rsa
|
||||||
|
# chmod 600 ~/.ssh/id_rsa
|
||||||
|
# ssh-add
|
||||||
|
|
|
@ -49,6 +49,11 @@
|
||||||
"ref": "origin/master",
|
"ref": "origin/master",
|
||||||
"repo": "git@github.com:leafac/www.kill-the-newsletter.com.git",
|
"repo": "git@github.com:leafac/www.kill-the-newsletter.com.git",
|
||||||
"path": "/root/www.kill-the-newsletter.com",
|
"path": "/root/www.kill-the-newsletter.com",
|
||||||
|
"pre-setup-documentation": [
|
||||||
|
"https://github.com/nodesource/distributions#debinstall",
|
||||||
|
"https://certbot.eff.org/docs/install.html"
|
||||||
|
],
|
||||||
|
"pre-setup": "ssh -o StrictHostKeyChecking=no git@github.com; apt-get update; apt-get install -y build-essential software-properties-common; curl -sL https://deb.nodesource.com/setup_13.x | bash -; add-apt-repository universe; add-apt-repository ppa:certbot/certbot; apt-get install -y nodejs certbot",
|
||||||
"ssh_options": [
|
"ssh_options": [
|
||||||
"ForwardAgent=yes",
|
"ForwardAgent=yes",
|
||||||
"StrictHostKeyChecking=no"
|
"StrictHostKeyChecking=no"
|
||||||
|
|
53
src/tasks.ts
53
src/tasks.ts
|
@ -1,54 +1,5 @@
|
||||||
import child_process from "child_process";
|
// execInFolder(`git pull origin master`);
|
||||||
|
// execInFolder(`npm ci`);
|
||||||
switch (process.argv[2]) {
|
|
||||||
case "provision":
|
|
||||||
child_process.execSync(`ssh-add`);
|
|
||||||
|
|
||||||
// https://github.com/nodesource/distributions#debinstall
|
|
||||||
// https://certbot.eff.org/docs/install.html
|
|
||||||
exec(`apt-get update`);
|
|
||||||
exec(`apt-get install -y build-essential software-properties-common`);
|
|
||||||
exec(`curl -sL https://deb.nodesource.com/setup_13.x | bash -`);
|
|
||||||
exec(`add-apt-repository universe`);
|
|
||||||
exec(`add-apt-repository ppa:certbot/certbot`);
|
|
||||||
exec(`apt-get install -y nodejs certbot`);
|
|
||||||
|
|
||||||
exec(`git clone git@github.com:leafac/www.kill-the-newsletter.com.git`);
|
|
||||||
break;
|
|
||||||
case "deploy":
|
|
||||||
child_process.execSync(`ssh-add`);
|
|
||||||
|
|
||||||
execInFolder(`git pull origin master`);
|
|
||||||
execInFolder(`npm ci`);
|
|
||||||
// TODO: rsync
|
// TODO: rsync
|
||||||
// TODO: $ pm2 startup OR $ pm2 save
|
// TODO: $ pm2 startup OR $ pm2 save
|
||||||
// TODO: $ pm2 start env.js --watch --ignore-watch="node_modules"
|
// TODO: $ pm2 start env.js --watch --ignore-watch="node_modules"
|
||||||
break;
|
|
||||||
default:
|
|
||||||
console.error(
|
|
||||||
`Unknown invocation: ${JSON.stringify(process.argv, undefined, 2)}`
|
|
||||||
);
|
|
||||||
process.exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
function exec(command: string): void {
|
|
||||||
console.log("$", command);
|
|
||||||
child_process.execFileSync(
|
|
||||||
"ssh",
|
|
||||||
["-tA", "root@kill-the-newsletter.com", command],
|
|
||||||
{ stdio: "inherit" }
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
function execInFolder(command: string): void {
|
|
||||||
exec(`cd www.kill-the-newsletter.com && env NODE_ENV=production ${command}`);
|
|
||||||
}
|
|
||||||
|
|
||||||
// - run: |
|
|
||||||
// mkdir ~/.ssh
|
|
||||||
// echo "${{ secrets.SECRET_PRIVATE_DEPLOY_KEY }}" > ~/.ssh/id_rsa
|
|
||||||
// chmod 600 ~/.ssh/id_rsa
|
|
||||||
|
|
||||||
// https://github.com/webfactory/ssh-agent
|
|
||||||
|
|
||||||
// root 'apt-get install -y curl file git'
|
|
||||||
|
|
Loading…
Reference in New Issue