expect 实现 自动打包和提交代码到github

12 篇文章 0 订阅
9 篇文章 0 订阅

问题:web项目用gulp压缩处理之后,提交到github 需要2次执行命令,想把这个流程合并

解决:expect交互式命令提交

build_push.sh, 下载:build_push.sh

#!/usr/bin/bash
gulp
rsync -avr build/* .
git add *
git ci -am 'update this repo'
echo "start push .."
expect ~/.account/github.sh

~/.account/github.sh

#!/usr/bin/expect
spawn git push origin master
expect "Username for 'https://github.com':"
#uname 和 upwd 是用户名和密码
send "uname\r"
expect "Password for 'https://uname@github.com':"
send "upwd\r"


在终端执行:

sh build_push.sh

输出:

[17:53:59] Using gulpfile /wwwroot/gulpfile.js
[17:53:59] Starting 'clean'...
[17:53:59] Starting 'html'...
[17:53:59] Starting 'images'...
[17:53:59] Finished 'images' after 21 ms
[17:53:59] Finished 'html' after 81 ms
[17:53:59] Starting 'scripts'...
[17:53:59] Starting 'css'...
[17:53:59] Finished 'scripts' after 182 ms
[17:53:59] Finished 'css' after 176 ms
building file list ... done
back.html
contact.html
front.html
index.html
css/
css/main_9ab4e08326b09c17198fec12f53afa8a.css
css/normalize_db1aae18a50d64dc7d57cc30890fa4a9.css
js/
js/html5shiv_d63094dbbc4dfc1e461663fd73072b41.js
js/statis_e3bfbbc174f0286942c0966544bce390.js


sent 17018 bytes  received 208 bytes  34452.00 bytes/sec
total size is 16281  speedup is 0.95
The following paths are ignored by one of your .gitignore files:
build
node_modules
src
Use -f if you really want to add them.
[master e05f1cc] update this repo
 2 files changed, 8 insertions(+), 1 deletion(-)
 create mode 100644 build_push.sh
start push ..
spawn git push origin master
Username for 'https://github.com': robertzhai
Password for 'https://robertzhai@github.com':
Counting objects: 4, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (3/3), done.
Writing objects: 100% (4/4), 461 bytes | 0 bytes/s, done.
Total 4 (delta 1), reused 0 (delta 0)
remote: Resolving deltas: 100% (1/1), completed with 1 local objects.
To https://github.com/robertzhai/robertzhai.github.io.git
   6493d82..e05f1cc  master -> master
 end push ...



  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值