-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(ci): add next-update-travis, close #110
- Loading branch information
Showing
4 changed files
with
62 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
#!/bin/bash | ||
|
||
set -e | ||
|
||
if [ "$TRAVIS_EVENT_TYPE" = "cron" ]; then | ||
if [ "$GH_TOKEN" = "" ]; then | ||
echo "" | ||
echo "⛔️ Cannot find environment variable GH_TOKEN ⛔️" | ||
echo "Please set it up for this script to be able" | ||
echo "to push results to GitHub" | ||
echo "ℹ️ The best way is to use semantic-release to set it up" | ||
echo "" | ||
echo " https://github.com/semantic-release/semantic-release" | ||
echo "" | ||
echo "npm i -g semantic-release-cli" | ||
echo "semantic-release-cli setup" | ||
echo "" | ||
exit 1 | ||
fi | ||
|
||
echo "Upgrading dependencies using next-update" | ||
npm i -g next-update | ||
|
||
# you can edit options to allow only some updates | ||
# --allow major | minor | patch | ||
# --latest true | false | ||
# see all options by installing next-update | ||
# and running next-update -h | ||
next-update --allow minor --latest false | ||
|
||
git status | ||
# if package.json is modified we have | ||
# new upgrades | ||
if git diff --name-only | grep package.json > /dev/null; then | ||
echo "There are new versions of dependencies 💪" | ||
git add package.json | ||
echo "----------- package.json diff -------------" | ||
git diff --staged | ||
echo "-------------------------------------------" | ||
git config --global user.email "next-update@ci.com" | ||
git config --global user.name "next-update" | ||
git commit -m "chore(deps): upgrade dependencies using next-update" | ||
# push back to GitHub using token | ||
git remote remove origin | ||
# TODO read origin from package.json | ||
# or use github api module github | ||
# like in https://github.com/semantic-release/semantic-release/blob/caribou/src/post.js | ||
git remote add origin https://next-update:$GH_TOKEN@github.com/bahmutov/pre-git.git | ||
git push origin HEAD:master | ||
else | ||
echo "No new versions found ✋" | ||
fi | ||
else | ||
echo "Not a cron job, normal test" | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters