Storybook
// todo..
github access tokens
先在github中创建一个access tokens ( 给到travis )
setting => Developer settings => Personal access tokens => Generate new token
创建后复制保存
Travis
登录travis,关联github和项目,在需要ci/cd的项目setting中把access tokens添加进去
变量命名为github_token(后面会用到)
配置项目文件
在项目根目录添加.travis.yml
language: node_js
node_js:
- 'stable'
cache:
directories:
- node_modules
env:
- CI=true
install:
- yarn
script:
- npm run build-storybook
deploy:
provider: pages
skip_cleanup: true
github_token: $github_token
local_dir: storybook-static
traget-branch: docs
on:
branch: main
其中
github_token为刚刚设置的变量名
traget-branch是希望travis自动推送的分支,如果不设置默认为gh-pages分支
推送
配置完毕,推送项目至main分支,可以看到travis自动触发部署
会看到travis自动部署到了dosc分支
配置github page
进入项目 => setting => github pages ,设置dosc分支和根路径
done
当travis构建失败时,可以尝试在github重新创建assess token,并重新添加到travis environment variables中