Travis.yml
push to different repo
# run the pipeline on changes in master branch
trigger:
- master
# build environment - OS
pool:
vmImage: 'ubuntu-latest'
steps:
# build environment - Node
- task: NodeTool@0
inputs:
versionSpec: '10.x'
displayName: 'install node.js'
# NPM task
- script: |
npm install
npm run build
displayName: 'npm install and build'
# Git task
- script: |
# remove git history and settings - to avoid inheritance
rm -rf .git
# re-initialise git
git init
git config user.name "<yourName>"
git config user.email "<yourEmail>"
git remote set-url origin https://<githubLogin>:${GIT_TOKEN}@github.com/<githubLogin>/<publicRepositoryName>.git
# add and commit /docs/ folder
git add docs
git commit -m "deploy the bundle"
# push the commit to the public repository
git push origin HEAD:master --force
displayName: 'deploy the production bundle'
language: node_js
node_js:
- lts/*
cache:
directories:
- node_modules
before_install:
- export TZ='Asia/Shanghai'
install:
- npm install hexo-cli -g
- npm install
script:
- hexo g
after_script:
- cd ./public
- git init
- git config user.name "your-git-name"
- git config user.email "your-email-address"
- git add .
- git commit -m "Travis CI Auto Builder at $(date +'%Y-%m-%d %H:%M:%S')"
- git push --force --quiet "https://${GH_TOKEN}@${GH_REF}" master:master
branches:
only:
- master
language: go
go:
- "1.8" # 指定Golang 1.8
# Specify which branches to build using a safelist
# 分支白名单限制:只有 master 分支的提交才会触发构建
# branches:
# only:
# - master
install:
# 安装最新的hugo
- wget https://github.com/gohugoio/hugo/releases/download/v0.51/hugo_0.51_Linux-64bit.deb
- sudo dpkg -i hugo*.deb
# 安装主题
- git clone [你使用的主题的 Git 地址]
script:
# 运行hugo命令
- hugo
after_script:
# 部署
- cd ./public
- git init
- git config user.name "[你的名字]"
- git config user.email "[你的邮箱]"
- git add .
- git commit -m "Update Blog By TravisCI With Build $TRAVIS_BUILD_NUMBER"
# Github Pages
- git push --force --quiet "https://$GITHUB_TOKEN@${GH_REF}" master:master
# Github Pages
- git push --quiet "https://$GITHUB_TOKEN@${GH_REF}" master:master --tags
env:
global:
# Github Pages
- GH_REF: [用来部署博客的 Git 地址]
deploy:
provider: pages # 重要,指定这是一份github pages的部署配置
skip-cleanup: true # 重要,不能省略
local-dir: public # 静态站点文件所在目录
# target-branch: master # 要将静态站点文件发布到哪个分支
github-token: $GITHUB_TOKEN # 重要,$GITHUB_TOKEN是变量,需要在GitHub上申请、再到配置到Travis
# fqdn: # 如果是自定义域名,此处要填
keep-history: true # 是否保持target-branch分支的提交记录
on:
branch: master # 博客源码的分支