Skip to content

Instantly share code, notes, and snippets.

@anzfactory
Created December 3, 2019 13:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anzfactory/4cf29ba4cd2c261449401d3a632bc0f8 to your computer and use it in GitHub Desktop.
Save anzfactory/4cf29ba4cd2c261449401d3a632bc0f8 to your computer and use it in GitHub Desktop.
bitrise.ymlをダウンロードしてきて差異があればPRをつくるやつ。Scriptステップでつかえる。
#!/usr/bin/env bash
# fail if any commands fails
set -e
# debug log
set -x
# download bitrise.yml
curl -O -H "Authorization: token ${BITRISE_API_ACCESS_TOKEN}" "https://api.bitrise.io/v0.1/apps/${BITRISE_APP_SLUG}/bitrise.yml"
# check diff
if git diff --quiet --exit-code ; then
exit 0
fi
# add
git add bitrise.yml
# install hub command
if which hub > /dev/null ; then
echo "hub installed"
else
echo "install hub"
brew install hub
fi
# config hub
mkdir -p $HOME/.config
echo "github.com:
- oauth_token: $GITHUB_ACCESS_TOKEN
user: $GITHUB_USER_NAME
protocol: https
" > "$HOME/.config/hub"
# prepare pull request
message="update bitrise.yml"
now=$(date "+%Y-%m-%d_%H-%M-%S")
branchName="up/bitrise-$now"
fileName="pr.txt"
echo "update bitrise.yml" > "$fileName"
# chckout branch
git checkout -b "$branchName"
# commit
git -c user.name="$GITHUB_USER_NAME" -c user.email="${GITHUB_USER_NAME}@users.noreply.github.com" commit -m "$message"
# create pull request
git push origin "$branchName"
hub pull-request -F "$fileName" -b develop
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment