下面是我的.travis.yml,我使用grunt来编译我的sass,并尽量减lessjs和图像,似乎工作正常,但没有这些文件部署到Elastic Beanstalk。 我添加了skip_cleanup: true根据文档应该解决这个问题,但无济于事。
language: php before_install: - nvm install 0.10.38 - npm set progress=false - npm install -g grunt-cli grunt grunt-bower -loglevel=error - gem install dpl script: - echo "success" before_deploy: - cd ${TRAVIS_BUILD_DIR}/wp-content/themes/myapp && npm install --loglevel=error - cd ${TRAVIS_BUILD_DIR}/wp-content/themes/myapp && grunt build - cd ${TRAVIS_BUILD_DIR} - ls ${TRAVIS_BUILD_DIR}/wp-content/themes/myapp env: - ELASTIC_BEANSTALK_LABEL=$TRAVIS_COMMIT deploy: skip_cleanup: true provider: elasticbeanstalk region: us-east-1 app: App env: app-staging bucket-name: elasticbeanstalk-us-east-1-AAAAAAAA123 access_key_id: ${STAGING_AWS_ACCESS_KEY_ID} secret_access_key: ${STAGING_AWS_SECRET_KEY} on: branch: staging
我从来没有find答案,只使用Travis构build和发布,我不得不在travis运行grunt构build之后手动创build一个zip文件,并使用awscli将其上传到s3并触发EB部署。
.travis.yml
language: node_js node_js: - 0.10 before_install: - sudo pip install awscli - ls /usr/local/bin/ - which aws - npm set progress=false - npm install -g grunt-cli grunt grunt-bower -loglevel=error script: - echo "success" before_deploy: - cd ${TRAVIS_BUILD_DIR}/wp-content/themes/mytheme && npm install --loglevel=error - cd ${TRAVIS_BUILD_DIR}/wp-content/themes/mytheme && grunt build - cd ${TRAVIS_BUILD_DIR} - echo $(git rev-parse --short HEAD) >> /tmp/version - cd ${TRAVIS_BUILD_DIR} && zip -0 /tmp/travisci-$(cat /tmp/version).zip -r ./ -x "wp-content/themes/mytheme/node_modules/*" "*.git*" > /dev/null - chmod +x scripts/deploy/production.sh deploy: - provider: script skip_cleanup: true script: scripts/deploy/production.sh on: branch: master
脚本/部署/ production.sh
mkdir ~/.aws touch ~/.aws/config chmod 600 ~/.aws/config echo "[default]" > ~/.aws/config echo "aws_access_key_id = $AWS_ACCESS_KEY_ID" >> ~/.aws/config echo "aws_secret_access_key = $AWS_SECRET_ACCESS_KEY" >> ~/.aws/config cp ~/.aws/config ~/.aws/credentials aws s3 cp /tmp/travisci-*.zip s3://elasticbeanstalk-us-east-1-1234567890/ aws elasticbeanstalk create-application-version --region us-east-1 --application-name "app" --version-label `cat /tmp/version` --source-bundle S3Bucket="elasticbeanstalk-us-east-1-1234567890",S3Key="travisci-`cat /tmp/version`.zip" aws elasticbeanstalk update-environment --region us-east-1 --environment-name "app-production" --version-label `cat /tmp/version`
我想这是因为部署工具使用git ls-files来select要部署的文件。 要解决您的问题,可以在部署之前使用git add -f ignored_folder ,或者尝试修改.gitignore 。