Created
December 3, 2019 13:14
-
-
Save anzfactory/4cf29ba4cd2c261449401d3a632bc0f8 to your computer and use it in GitHub Desktop.
bitrise.ymlをダウンロードしてきて差異があればPRをつくるやつ。Scriptステップでつかえる。
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
#!/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