greenkeeper-yarn.sh 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. #!/bin/bash
  2. echo "Should yarn.lock be regenerated?"
  3. if [[ $TRAVIS_PULL_REQUEST_BRANCH != *"greenkeeper"* ]]; then
  4. # Not a GreenKeeper Pull Request, aborting
  5. exit 0
  6. fi
  7. echo "Cloning repo"
  8. git clone "https://"$PUSH_TOKEN"@github.com/"$TRAVIS_REPO_SLUG".git" repo
  9. cd repo
  10. echo "Switching to branch $TRAVIS_PULL_REQUEST_BRANCH"
  11. git checkout $TRAVIS_PULL_REQUEST_BRANCH
  12. # See if commit message includes "update"
  13. git log --name-status HEAD^..HEAD | grep "chore(package)" || exit 0
  14. echo "Updating lockfiles"
  15. yarn
  16. PACKAGE=`echo "$TRAVIS_PULL_REQUEST_BRANCH" | sed 's/[^/]*\/\(.*\)/\1/' | sed 's/\(.*\)-[^-]*/\1/'`
  17. cd examples/node && echo "Check $PACKAGE in examples/node"
  18. cat package.json | grep "\"$PACKAGE\":" && yarn upgrade $PACKAGE
  19. cd -
  20. cd examples/protractor && echo "Check $PACKAGE in examples/protractor"
  21. cat package.json | grep "\"$PACKAGE\":" && yarn upgrade $PACKAGE
  22. cd -
  23. cd examples/typescript && echo "Check $PACKAGE in examples/typescript"
  24. cat package.json | grep "\"$PACKAGE\":" && yarn upgrade $PACKAGE
  25. cd -
  26. echo "Commit and push yarn.lock"
  27. git config --global user.email "$PUSH_EMAIL"
  28. git config --global user.name "Travis CI"
  29. git config --global push.default simple
  30. git add yarn.lock examples/node/yarn.lock examples/protractor/yarn.lock examples/typescript/yarn.lock
  31. git commit -m "chore(yarn.lock): update yarn.lock"
  32. git push