Use Travis + github + hexo the continued deployment of the project blog

First, the githubbasic operation

  • 1. Create a hexo_blogproject

  • 2, generates a personal account token(note that this place is generated tokenmust be copied immediately, refresh the page to see it)

    Click on the top right corner of the picture settings---> Developer settings---> Personal access tokens--->genderate new token

Second, the use hexostation document address

  • 1, according to the official website of the steps step by step
  • 2, just to build a project submitted by the githubwarehouse

Third, the use travissustained deployment project 's official website address

  • 1, Travis CIprovides a continuous integration service ( Continuous Integrationabbreviated CI). It binds Githubthe above items, as long as the new code, it will automatically crawl. Then, provide a runtime environment, a test is performed to complete the building, but also deployed to the server
  • 2, continuous integration means that as long as the code has changed, automatically run the build and test, feedback the results. Ensure compliance with expected future, then the new code is integrated into the trunk
  • 3, continuous integration benefits that small changes each time the code, you can see the results in order to accumulate small changes, rather than at the end of the development cycle, all of a sudden a chunk of code merger
  • 4, Travis CIonly support Github, so you have to have GitHuban account
  • 5, click Sign in with GitHubthe button, use the githubaccount login

  • 6, synchronize githubthe items on the

  • 7, the synchronization is provided just githubon the generatedtokon

Fourth, the .travis.ymlpaper prepared

  • 1, Travisrequires the root directory of the project, there must be a .travis.ymlfile. This is the configuration file that specifies the Travisbehavior

  • 2, the file must be saved in the Githubrepository, once the new code repository Commit,Traviswill find this file, execute commands inside

  • 3, the use of this document YAMLformat. Here is a simple Node project .travis.ymlfile

  • 4, languagefield specifies the default operating environment, all of the language in this

  • 5 node_js: "11" does not perform any script, direct the state to succeed

  • 6, the specific configuration ()

    language: node_js
    node_js:
      - '11'
    install:
      - npm install
    script:
      - hexo g
    after_script:
      - cd ./public
      - git init
      - git config user.name ${USERNAME}
      - git config user.email ${UESREMAIL}
      - git add -A
      - git commit -m 'init'
      - git push -u -f "https://${TOKEN}@github.com/${USERNAME}/hexo_blog" master:gh-pages
    branches:
      only:
        - master
    复制代码

Fifth, modify hexoconfiguration files

While directly to the above code can be automatically released, but the style is loaded out the official website of documents

  • 1, modify the _config.ymlfile

    url: https://kuangshp.github.io/hexo_blog/
    root: /hexo_blog/
    复制代码

Six, so that each gitsubmit code traviswill automatically help you publish a project

Seven, to view static site address (in the githubopen setting of items on the down turn)

Guess you like

Origin blog.csdn.net/weixin_34066347/article/details/91365276