travis-ci how to push to master branch

霸气de小男生 提交于 2019-12-06 14:15:30

I found most articles or answers were talking about how to deploy to gh-pages branch, and most ways is not work for me , i debug this issue on travis for several days, i will list key steps about how to push to master brach on travis

e.g. Below is my doc repository script, travis will update readme.md automated.

  1. Generate github token, you can refer to the article https://help.github.com/articles/creating-a-personal-access-token-for-the-command-line/

  2. Set Environment Variables

    GH_REF githu.com/clownvary/docs.git your repository address

    GITHUB_API_KEY *********** your token generated on step 1

  3. Script

    os: osx
    language: node_js
    cache:
      directories:
        - node_modules
    node_js:
      - 'lts/*'
    before_install:
      - git pull
      - brew install tree
    install:
      - npm install
    script:
      - npm run updateReadme
    after_success:
      - git config user.email "travis@travis.org"
      - git config user.name "travis" # this email and name can be set anything you like
      - git add README.md
      - git commit --allow-empty -m "updated README.md"
      - git push https://clownvary:${GITHUB_API_KEY}@${GH_REF} HEAD:master  #clownvary is my username on github, you need to use yourself , do not use travis or others.
    

Hope this can help you

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!