Skip to content

Instantly share code, notes, and snippets.

@vensing
Last active April 18, 2020 06:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vensing/0296bf555c794d4392c05c75ce00d17c to your computer and use it in GitHub Desktop.
Save vensing/0296bf555c794d4392c05c75ce00d17c to your computer and use it in GitHub Desktop.
Travis CI config file
language: node_js
node_js: stable
sudo: false
#cache
cache:
apt: true
directories:
- "node_modules"
addons:
ssh_known_hosts:
- github.com
- vensing.com
notifications:
email:
recipients:
- vensing@foxmail.com
on_success: never
on_failure: never
# S: Build Lifecycle
install:
- npm install
- git clone -b custom https://github.com/vensing/Kratos-Rebirth.git themes/Kratos-Rebirth
# - travis login --pro --github-token ${GH_TOKEN}
before_script:
# 解密 RSA 私钥并设置为本机 ssh 私钥
- openssl aes-256-cbc -K $encrypted_383bc2ea2d21_key -iv $encrypted_383bc2ea2d21_iv
-in travis/travis.key.enc -out ~/.ssh/id_rsa -d
- chmod 600 ~/.ssh/id_rsa
- export TZ='Asia/Shanghai'
- chmod +x _travis.sh
script:
- hexo clean && hexo g
after_success:
# - LAST_BUILD_NUMBER=68
# - for i in $(seq 1 $LAST_BUILD_NUMBER ); do travis logs $i --delete --force ; done
- rsync -rv --delete -e 'ssh -o stricthostkeychecking=no -p 22' public/ root@www.vensing.com:/hexo
after_script:
- ./_travis.sh
# E: Build LifeCycle
branches:
only:
- source
#env:
# global:
# - GH_REF: github.com/vensing/vensing.github.io.git
#--------------------------------------------
#!/bin/bash
#--------------------------------------------
#定义时间
time=`date +%Y-%m-%d\ %H:%M:%S`
#执行成功
function success(){
echo "success"
}
#执行失败
function failure(){
echo "failure"
}
#默认执行
function default(){
git clone git@github.com:vensing/vensing.github.io.git .deploy_git
cd .deploy_git
git checkout master
cd ../
mv .deploy_git/.git/ ./public/
cd ./public
cat <<EOF >> README.md
部署状态 | 集成结果 | 参考值
---|---|---
完成时间 | $time | yyyy-mm-dd hh:mm:ss
部署环境 | $TRAVIS_OS_NAME + $TRAVIS_NODE_VERSION | window \| linux + stable
部署类型 | $TRAVIS_EVENT_TYPE | push \| pull_request \| api \| cron
启用Sudo | $TRAVIS_SUDO | false \| true
仓库地址 | $TRAVIS_REPO_SLUG | owner_name/repo_name
提交分支 | $TRAVIS_COMMIT | hash 16位
提交信息 | $TRAVIS_COMMIT_MESSAGE |
Job ID | $TRAVIS_JOB_ID |
Job NUM | $TRAVIS_JOB_NUMBER |
EOF
git init
git config user.name "vensing"
git config user.email "782176881@qq.com"
git add .
git commit -m "Update Blog By TravisCI With Build $TRAVIS_BUILD_NUMBER"
# Github Pages
git push --force --quiet origin master:master
# Create Tag
#git tag v1.2.$TRAVIS_BUILD_NUMBER -a -m "Auto Taged By TravisCI With Build $TRAVIS_BUILD_NUMBER"
# Github Pages
#git push --force --quiet origin master:master --tags
}
case $1 in
"success")
success
;;
"failure")
failure
;;
*)
default
esac
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment