Skip to content

Commit

Permalink
Merge pull request #1 from karlsbeard/cloud
Browse files Browse the repository at this point in the history
chore: add deploy script
  • Loading branch information
gjssss authored Jan 5, 2025
2 parents 0fa3b11 + a7717c8 commit 066b432
Show file tree
Hide file tree
Showing 4 changed files with 99 additions and 13 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
node_modules
dist
dist
id_rsa
6 changes: 4 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@
"scripts": {
"dev": "vitepress dev",
"build": "vitepress build",
"preview": "vitepress preview"
"preview": "vitepress preview",
"dep": "pnpm build && zx ./script/deploy.mjs"
},
"devDependencies": {
"vitepress": "^1.5.0"
"vitepress": "^1.5.0",
"zx": "^8.3.0"
},
"dependencies": {
"@vue/theme": "^2.3.0",
Expand Down
75 changes: 65 additions & 10 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

28 changes: 28 additions & 0 deletions script/deploy.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#!/usr/bin/env zx

import { $, cd, echo } from "zx";

const secret_key = './secret/id_rsa'

const { stdout } = await $`test -f ${secret_key} && echo true || echo false`
if (stdout.trim() === 'false') {
echo('Secret key not found')
$`exit`
}

function exec_remote_cmd(cmd) {
return $`ssh -i ${secret_key} [email protected] '${cmd}'`
}

function upload_file(file_path){
return $`scp -i ${secret_key} ${file_path} [email protected]:/home/ubuntu/jobs_ci`
}

echo('Deploying...')
cd('.vitepress/dist')
await $`zip -r dist.zip .`
cd('../..')
await upload_file('./.vitepress/dist/dist.zip')
await $`rm ./.vitepress/dist/dist.zip`
await exec_remote_cmd(`sudo bash /home/ubuntu/jobs_ci/ci.sh`)
echo('Deployed!')

0 comments on commit 066b432

Please sign in to comment.