Travis无法部署dist文件夹

时间:2018-08-31 07:17:03

标签: javascript continuous-integration travis-ci web-deployment continuous-deployment

我正在尝试通过travis cli部署我们的应用程序,该构建可以完美构建,但是在部署时,它会部署整个根应用程序文件夹。 我想要的是部署由构建生成的dist文件夹,所以当我执行cd dist before_deploy时,它什么都不会部署(我检查aws bucket,travis.zip文件变为22字节)。要检查dist及其内容是否存在,我在此处运行ls命令,它向我展示了正确构建的应用程序结构。

为了进行测试,我尝试将代码压缩到不同的文件夹中并进行部署,在所有情况下,travis都可以部署它,但不能部署gitignore下的目录,而dist是其中之一。

由于我不想在回购中使用dist,我们如何删除此限制?

这是我的代码

language: node_js
node_js:
- 8.9.4
cache:
  directories:
  - node_modules
before _script:
- npm install
script:
  - npm run build-staging
  - gulp copy-package
  - if [ "$TRAVIS_BRANCH" = "prod" ] && [ "$TRAVIS_PULL_REQUEST" = "false" ]; then npm run build-prod; else echo "PR skip deploy"; fi
before_deploy:
  - ls
  - cd $TRAVIS_BUILD_DIR/node_modules
  - ls
deploy:
  - provider: elasticbeanstalk
    access_key_id: access_id
    secret_access_key:
      secure: secret_key
    region: eu-west-1
    app: yop-v3
    env: yop-staging-test
    bucket_name: elasticbeanstalk-eu-west-1-123456789
    skip_cleanup: true
    on:
      repo: company/repo-name
      branch: travis2
after_deploy:
  - ls

1 个答案:

答案 0 :(得分:0)

您需要指定要部署的local_dir(在这种情况下为dist

deploy:
  - provider: elasticbeanstalk
    access_key_id: access_id
    secret_access_key:
      secure: secret_key
    region: eu-west-1
    local_dir: dist        //here       
    app: yop-v3
    env: yop-staging-test
    bucket_name: elasticbeanstalk-eu-west-1-123456789
    skip_cleanup: true
    on:
      repo: company/repo-name
      branch: travis2