1

Below is my .travis.yml, I'm using grunt to compile my sass, and minimize js and images which seem to work fine, however none of those files get deployed to Elastic Beanstalk. I added skip_cleanup: true which according to the docs should fix this issue but to no avail.

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
Stefan
  • 141
  • 1
  • 6

2 Answers2

0

I never did find an answer to this using only travis to build and ship, I had to manually create a zip file after Travis ran grunt build and use awscli to upload it to s3 and trigger an EB deployment.

.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

scripts/deploy/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`
Stefan
  • 141
  • 1
  • 6
0

I think it's because the deploy tool uses git ls-files to select the files for deployment. To work around you can either use git add -f ignored_folder before deploy or try to modify .gitignore on the fly.