Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
yulii committed Aug 15, 2017
1 parent fc0f142 commit 0b74976
Showing 1 changed file with 6 additions and 33 deletions.
39 changes: 6 additions & 33 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,46 +30,19 @@ jobs:
update:
docker:
- image: circleci/node:7.10
environment:
FORK_USERNAME: yulii-bot
UPDATE_LOCK_FILE: yarn.lock
steps:
- run:
name: Checkout code
command: git clone -b master --depth 1 https://${FORK_REPO_TOKEN}@github.com/yulii-bot/hubot-scripts.git .
- run:
name: Syncing fork
command: |
git remote add upstream https://github.com/yulii/hubot-scripts.git
git fetch upstream
git checkout master
git merge upstream/master
command: sh -c "$(curl -fsSL https://raw.githubusercontent.com/yulii/fork-update/master/checkout)"
- run:
name: Update dependencies
command: yarn upgrade
- run:
name: Commit auto update file
command: |
test -z "$(git status -s yarn.lock 2> /dev/null)" && echo 'No update.' && exit 0
BRANCH="update-$(sha1sum yarn.lock | cut -d' ' -f1)"
test -n "$(git ls-remote origin ${BRANCH} 2> /dev/null)" && echo 'Already committed.' && exit 0
git config --local user.email 'yuliinfo+bot@gmail.com'
git config --local user.name 'yulii-bot'
git add yarn.lock
git commit -m 'Bundle update'
git branch -M ${BRANCH}
git push origin ${BRANCH}
- run:
name: Send auto update pull request
command: |
BRANCH="update-$(sha1sum yarn.lock | cut -d' ' -f1)"
test -z "$(git ls-remote origin ${BRANCH} 2> /dev/null)" && echo "Update branch not found." && exit 0
git fetch origin ${BRANCH}
test -z "$(git diff upstream/master...FETCH_HEAD)" && echo "No changes." && exit 0
curl -s -X POST \
-H "Authorization: token ${FORK_REPO_TOKEN}" \
-H "Content-Type: application/json" \
-d "{ \"title\": \"Yarn upgrade\", \"body\": \"Auto update pull request!\", \"head\": \"yulii-bot:${BRANCH}\", \"base\": \"master\" }" \
"https://api.github.com/repos/yulii/hubot-scripts/pulls" \
| tee /tmp/create-pull-request.log.json
test -n "$(cat /tmp/create-pull-request.log.json | jq -r 'select(.errors == null)')"
command: sh -c "$(curl -fsSL https://raw.githubusercontent.com/yulii/fork-update/master/pull-request)"

workflows:
version: 2
Expand All @@ -81,4 +54,4 @@ workflows:
- build
filters:
branches:
only: master
only: fork-update-script

0 comments on commit 0b74976

Please sign in to comment.