用 travis-ci 自动部署 github 上的 angular2 项目到 centos7 的 vps
2017-05-29 21:19
811 查看
概述
在 vps 上, 为运行着travis的系统生成公钥和私钥, 公钥放在 vps 上, 私钥放到项目目录中, 然后被
travis拉到系统, 这样, 在
travis访问 vps 时就可以免密码了
以下所有操作均在 vps 上执行
环境
vps:kylin-ux.com
vps 操作系统:
CentOS Linux release 7.3.1611 (Core)
github: https://github.com/shuhm-gh/kdb
本地对应项目目录:
/opt/www/kdb
确定 nodejs
最新版本
安装 nvm
git clone https://github.com/creationix/nvm.git cd nvm/; ./install.sh source /root/.bash_profile
查看版本
nvm list-remote
6.10.3为最新版本, 作为
.travis.yml中
node_js:的值
为 travis
生成密钥
ssh-keygen -f travis
为 vps 添加 travis
的公钥
cat travis.pub >> ~/.ssh/authorized_keys
加密 travis
私钥
# 切换到项目目录 cd /opt/www/kdb/ yum install gem yum install ruby-devel gem install travis travis login # github 帐号和密码 cp /root/travis .travis/ travis encrypt-file .travis/travis --add # --add 会将解密命令添加到 .travis.yml
--add修改的内容
before_install: - openssl aes-256-cbc -K $encrypted_9d6a078f2a50_key -iv $encrypted_9d6a078f2a50_iv -in travis.enc -out .travis/travis -d
提交到 github
git add -A git commit -m 'travis' git push
查看 https://www.travis-ci.org/
.travis.yml
完整内容
language: node_js
node_js:
- 6.10.3
script:
- ssh -i .travis/travis root@kylin-ux.com cd /opt/www/kdb/; git pull; npm build
branches:
only:
- master
before_install: - openssl aes-256-cbc -K $encrypted_9d6a078f2a50_key -iv $encrypted_9d6a078f2a50_iv -in travis.enc -out .travis/travis -d
- chmod 600 .travis/travis
addons:
ssh_known_hosts: kylin-ux.com
补充
Q:The authenticity of host ‘192.168.0.110 (192.168.0.110)’ can’t be established. RSA key fingerprint is a3:ca:ad:95:a1:45:d2:57:3a:e9:e7:75:a8:4c:1f:9f. Are you sure you want to continue connecting (yes/no)?
A:
echo -e "Host 102.201.64.94\n\tStrictHostKeyChecking no\n" >> ~/.ssh/config
或
ssh加选项
-o stricthostkeychecking=no
Q: 免密
A:
travis encrypt DEPLOY_USER=<csun-username> travis encrypt DEPLOY_PASS=<csun-password> export SSHPASS=$DEPLOY_PASS sshpass -e ssh $DEPLOY_USER@kylin-ux.com
相关文章推荐
- 使用travis-ci自动部署github上的项目
- 使用travis-ci自动部署github上的项目
- HG - Hexo + GitHub + Travis CI = 自动部署博客实现
- 为GitHub项目加入Travis-CI的自动集成
- GitHub项目加入Travis-CI的自动集成
- 手把手教从零开始在GitHub上使用Hexo搭建博客教程(四)-使用Travis自动部署Hexo(2)
- VPS(centos)部署web项目
- 手把手教从零开始在GitHub上使用Hexo搭建博客教程(四)-使用Travis自动部署Hexo(2)
- CI学习一:maven项目自动部署到tomcat
- GitHub利用webhook实现push时项目自动部署
- 手把手教从零开始在GitHub上使用Hexo搭建博客教程(三)-使用Travis自动部署Hexo(1)
- 手把手教从零开始在GitHub上使用Hexo搭建博客教程(三)-使用Travis自动部署Hexo(1)
- 使用snap ci+GitHub将一个Java Web项目部署到Heroku
- IIS部署的新项目自动关闭
- 用Ant实现Java项目的自动构建和部署
- Eclipse自动部署项目到Tomcat的webapps下的有效方法
- 在部署项目时实现自动安装FrameWork及数据访问部件
- 用Ant实现Java项目的自动构建和部署
- VPS centos 5 系统启动自动同步以及定时任务同步系统日期时间
- 在eclipse下自动部署项目