【问题标题】:Is there a way to configure Travis GitHub Pages Deployment within stages?有没有办法分阶段配置 Travis GitHub Pages Deployment?
【发布时间】:2018-10-29 12:47:10
【问题描述】:

预期

能够在 Travis 中使用阶段将页面部署到 GitHub。

结果

失败,我一定没有合适的合成器,否则不可能。

复制

来源:

项目:

这项用于构建无阶段页面的工作:See the passing travis job : travis-ci.org/kopax/deleteme/builds/380660202:

dist: trusty

# Blocklist
branches:
  except:
    - gh-pages # will be deployed to, no need to build it

cache:
  directories:
    - node_modules

node_js:
  - "10"

before_install:
    - npm install -g npm
    # const
    - export PACKAGE_NAME=$(node -p "require('./package.json').name")
    - export PACKAGE_VERSION=$(node -p "require('./package.json').version")
    - export NODE_VERSION=$(node --version)
    - export NPM_VERSION=$(npm --version)

    # logging
    - npm --version || echo npm not installed
    - node --version|| echo node not installed
    - npx rollup-umd-scripts --version || echo npx not installed
    - echo "package version $PACKAGE_VERSION"

language: node_js
sudo: required
script:
  # execute all of the commands which need to be executed
  # before running actual tests
  - npm run styleguide:build


deploy:
  provider: pages
  skip_cleanup: true
  github_token: $GH_TOKEN  # Set in the settings page of your repository, as a secure variable
  keep_history: true
  local_dir: public/
  on:
    branch: master

但是当将页面部署添加为阶段 See this failed travis job: travis-ci.org/kopax/deleteme/jobs/380983577 时,这将失败:

language: node_js
sudo: required

#env:
#  global:
#    - DISPLAY=:99.0
#    - NODE_ENV=test
dist: trusty

# Blocklist
branches:
  except:
    - gh-pages # will be deployed to, no need to build it

cache:
  directories:
    - node_modules

node_js:
  - "10"

before_install:
    - npm install -g npm
    # const
    - export PACKAGE_NAME=$(node -p "require('./package.json').name")
    - export PACKAGE_VERSION=$(node -p "require('./package.json').version")
    - export NODE_VERSION=$(node --version)
    - export NPM_VERSION=$(npm --version)

    # logging
    - npm --version || echo npm not installed
    - node --version|| echo node not installed
    - npx rollup-umd-scripts --version || echo npx not installed
    - echo "package version $PACKAGE_VERSION"

stages:
  - build
  - test
  - release
  - deploy
script:
  # execute all of the commands which need to be executed
  # before running actual tests
  - npm run styleguide:build
jobs:
  include:
    # Job: Build
    - stage: build
      node_js:
        - lts/*
#        - 10
#        - 8
      script:
        - npm run build
      branches:
        only:
        - release
        - dev
        - master
    # Job: Test
    - stage: test
      node_js:
        - lts/*
#        - 10
#        - 8
      script:
        - npm run test
      branches:
        only:
        - release
        - dev
        - master
    # Job: Release
    - stage: release
      node_js:
        - lts/*
      skip_cleanup: true
      script:
        - npx semantic-release
      branches:
        only:
        - master
    # Job: Page
    - stage: deploy
      provider: pages
      skip_cleanup: true
      github_token: $GH_TOKEN  # Set in the settings page of your repository, as a secure variable
      keep_history: true
      local_dir: public/
      on:
        branch: master

有人知道如何在 Travis 中使用页面进行阶段部署吗?

【问题讨论】:

    标签: github continuous-integration travis-ci github-pages


    【解决方案1】:

    您的部署阶段没有定义安装/脚本,因此它采用默认设置。 您需要在阶段定义您想要做什么,您忘记了deploy 级别。 要仅用于部署的专用阶段,请将其配置如下:

    - stage: deploy
      if: type = push AND branch = master # or whenever you want to deploy
      script: skip # to not run Travis' default script
      deploy:      # <-- that was missing !!!
        - provider: pages
          skip_cleanup: true
          github_token: $GH_TOKEN  # Set in the settings page of your repository, as a secure variable
          keep_history: true
          local_dir: public/
    

    【讨论】:

    • 谢谢,太难找了。感谢您给我正确的合成器。这应该清楚地在 Travis 的文档中。
    猜你喜欢
    • 2015-10-23
    • 1970-01-01
    • 2015-03-28
    • 1970-01-01
    • 2015-11-29
    • 1970-01-01
    • 1970-01-01
    • 2016-06-23
    • 2019-09-30
    相关资源
    最近更新 更多