【问题标题】:Publish releases to gh-pages with travis without deleting previous releases使用 travis 将版本发布到 gh-pages 而不删除以前的版本
【发布时间】:2018-09-01 01:39:36
【问题描述】:

我想将版本发布到 gh-pages。可以将部署提供程序配置为使用 keep-history: true 保留历史记录。但是,我希望以前的版本不仅可以在 git 历史记录中使用,也不要从存储库中删除。

我已经配置了 yarn 和 webpack 来为每个标签创建一个单独的目录,并将分发放在一个“最新”目录以及这个标签特定的目录中。我想查看所有以前版本的标签目录,而不仅仅是最新版本。

这是我当前配置的结果:https://github.com/retog/rdfgraphnode-rdfext/tree/gh-pages

【问题讨论】:

    标签: github webpack travis-ci github-pages yarnpkg


    【解决方案1】:

    我找到了以下解决方案。

    travis.yml 中替换:

    - provider: pages
      skip-cleanup: true
      github-token: $GITHUB_TOKEN
      keep-history: true
      local-dir: distribution
      on:
        tags: true
    

    与:

    - provider: script
      script: bash .travis_publish
      on:
        tags: true
    

    并添加脚本文件.travis_publish,内容如下:

    #!/bin/bash
    PUBLICATION_BRANCH=gh-pages
    # Checkout the branch
    REPO_PATH=$PWD
    pushd $HOME
    git clone --branch=$PUBLICATION_BRANCH    https://${GITHUB_TOKEN}@github.com/$TRAVIS_REPO_SLUG publish 2>&1 > /dev/null
    cd publish
    # Update pages
    cp -r $REPO_PATH/distribution .
    # Commit and push latest version
    git add .
    git config user.name  "Travis"
    git config user.email "travis@travis-ci.org"
    git commit -m "Updated distribution."
    git push -fq origin $PUBLICATION_BRANCH 2>&1 > /dev/null
    popd
    

    【讨论】:

    • 由于我在另一个 repo 上不明白的原因,我不得不在进行克隆时在 repo URL 中添加后缀“.git”:git clone --branch=$PUBLICATION_BRANCH https://${GITHUB_TOKEN}@github.com/$TRAVIS_REPO_SLUG.git publish
    • 不再工作了:( cp: cannot stat '/home/travis/build/username/[secure]/distribution': No such file or directory
    • 别在意上面的评论,distribution 是你可能想要从你的 git repo 发布的路径。另一个脚本github.com/voorhoede/front-end-tooling-recipes/blob/master/…
    猜你喜欢
    • 2017-08-09
    • 1970-01-01
    • 2013-08-30
    • 2020-09-28
    • 1970-01-01
    • 1970-01-01
    • 2019-05-12
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多