# 持续集成
# SSH 协议文件传输
# ssh 自动认证密码登录远程服务器配置
添加一下配置到电脑目录/.ssh/config
Host myremote # any name for the host
HostName 192.168.178.05 # IP, .local, or hostname if defined
User username # your username
Port 22 # port to listen
1
2
3
4
5
6
7
2
3
4
5
6
7
设置完成后删除#开头的注释,不然回报 /Users/username/.ssh/config line 10: garbage at end of line; "#". 的错误,具体原因不是很清楚,只能先这样设置。
# 使用
ssh myremote
1
参考
https://www.jianshu.com/p/44060824ec2a (opens new window)
https://askubuntu.com/questions/257472/host-alias-for-ssh (opens new window)
# SCP 两台服务器无密码传输文件配置
- 将 主机 A
.ssh目录中的id_rsa.pub文件复制到 主机 B 的~/.ssh/目录中,并改名为authorized_keys。
scp .ssh/id_rsa.pub 192.168.10.2:/root/.ssh/authorized_keys
以后从 A 主机 scp 到 B 主机就不需要密码了
- 测试主机 A 文件 复制到主机 B
scp <dir>|<file> IP:/dirname
EXP. scp <dir> 192.168.1.1:/var/www
1
2
3
2
3
复制成功
# 项目持续集成方案
# github actions
在项目根目录新建
.github/workflows/目录结构,在workflows目录新建一个以yml为扩展名的文件,文件可以自由命名搜索
github官方的actions市场,选择一个适合自己的持续集成方案action,目前以actions-gh-pages为例配置文件如下
- name: Deploy
uses: peaceiris/actions-gh-pages@v3
with:
personal_token: ${{ secrets.PERSONAL_TOKEN }}
publish_dir: dist
allow_empty_commit: true
1
2
3
4
5
6
7
2
3
4
5
6
7
文件中的secrets.PERSONAL_TOKEN是个人github账号的生产的personal access token,需要为这个加密字段配置
repo访问的权限才能生效。
# Git hooks
npm install yorkie --save-dev
1
2
2
- 配置
package.json文件中的gitHooks字段
{
"gitHooks": {
"pre-push": "npm run deploy"
}
}
1
2
3
4
5
2
3
4
5
配置完成后,每次项目提交到远程仓库之前都会执行pre-push的命令