@@ -36,13 +36,25 @@ jobs:
36
36
- name : Build VitePress
37
37
run : yarn run docs:build
38
38
# 步骤6:部署到Github Pages
39
- - name : Deploy to Github Pages
40
- uses : peaceiris/actions-gh-pages@v3
39
+ # - name: Deploy to Github Pages
40
+ # uses: peaceiris/actions-gh-pages@v3
41
+ # with:
42
+ # github_token: ${{ secrets.VITEPRESS_BLOG_TOKEN }} # 自定义的action环境变量
43
+ # publish_dir: .vitepress/dist # 指定部署目录
44
+ # publish_branch: gh-pages # 指定部署分支
45
+ # dotfiles: true # 允许使用.gitignore文件
46
+ # 步骤7: scp部署到 vps
47
+ - name : Deploy to VPS
48
+ uses : appleboy/scp-action@master
41
49
with :
42
- github_token : ${{ secrets.VITEPRESS_BLOG_TOKEN }} # 自定义的action环境变量
43
- publish_dir : .vitepress/dist # 指定部署目录
44
- publish_branch : gh-pages # 指定部署分支
45
- dotfiles : true # 允许使用.gitignore文件
50
+ host : ${{ secrets.SERVER_HOST }} # 服务器地址
51
+ username : ${{ secrets.SERVER_USER }} # 服务器用户名
52
+ port : ${{ secrets.SERVER_PORT }} # 服务器端口
53
+ key : ${{ secrets.SERVER_SSH_KEY }} # 服务器SSH 密钥
54
+ # password: ${{ secrets.SERVER_USER_PASSWORD }} # 服务器用户密码
55
+ strip_components : 2 # 跳过指定目录
56
+ source : ' .vitepress/dist' # 源目录
57
+ target : ${{ secrets.SERVER_TARGET }} # 目标目录
46
58
` ` `
47
59
48
60
## 配置 Action 环境变量
@@ -66,12 +78,29 @@ jobs:
66
78
67
79

68
80
81
+ # # 配置action scp 部署到vps
69
82
83
+ 1. 登录 `vps` ,生成 `SSH` 秘钥
84
+
85
+ ` ` ` shell
86
+ # 生成ssh秘钥
87
+ ssh-keygen -t rsa -b 4096 -C "github-actions-node"
88
+ # 将公钥复制到服务器的authorized_keys文件中
89
+ cat /root/.ssh/id_rsa.pub >> authorized_keys
90
+ ` ` `
91
+ 1. 配置 `Actions Secrets`
92
+
93
+ ` ` ` shell
94
+ # 打印私钥,复制粘贴到github action环境变量中,命名为SSH_KEY
95
+ cat /root/.ssh/id_rsa
96
+ ` ` `
70
97
71
98
72
99
# # 参考
73
100
1. [GitHub Actions 入门教程](https://www.ruanyifeng.com/blog/2019/09/getting-started-with-github-actions.html)
74
101
1. [Github 管理个人访问令牌](https://docs.github.com/zh/authentication/keeping-your-account-and-data-secure/managing-your-personal-access-tokens)
75
102
1. [通过 Github Action 将 GitHub 上的内容部署到 VPS](https://tourcoder.com/deploy-from-github-to-vps-via-github-action/)
76
103
1. [使用 GitHub Actions 在代码更新时自动部署代码到 VPS](https://blog.csdn.net/m0_57236802/article/details/134216395)
77
- 1. [vitepress项目使用github的action自动部署到github-pages中](https://blog.csdn.net/weixin_43972992/article/details/135123018)
104
+ 1. [vitepress项目使用github的action自动部署到github-pages中](https://blog.csdn.net/weixin_43972992/article/details/135123018)
105
+ 1. [使用Github Actions自动部署Golang应用到VPS服务器](https://github.com/axiaoxin/axiaoxin/issues/27)
106
+ 1. [使用 GitHub Actions 部署 Next.js 项目到 VPS](https://riddma.com/post/deploy-next-js-to-vps-using-github-actions)
0 commit comments