Skip to content

Instantly share code, notes, and snippets.

@timers-ios
Created May 13, 2019 09:05
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 timers-ios/7676be80237f190b080f689aa61b5caa to your computer and use it in GitHub Desktop.
Save timers-ios/7676be80237f190b080f689aa61b5caa to your computer and use it in GitHub Desktop.
---
format_version: 1.1.0
default_step_lib_source: https://github.com/bitrise-io/bitrise-steplib.git
app:
envs:
- BITRISE_PROJECT_PATH: XXXX.xcworkspace
opts:
is_expand: false
- BITRISE_SCHEME: XXXX
opts:
is_expand: false
- opts:
is_expand: false
GITHUB_USER_NAME: xxxxxx
workflows:
outdated:
steps:
- activate-ssh-key: {}
- git-clone: {}
- cache-pull: {}
- script:
title: Check outdated
inputs:
- content: |-
#!/usr/bin/env bash
# fail if any commands fails
set -e
# debug log
set -x
pod install
POD_OUTDATED=`pod outdated`
CARTHAGE_OUTDATED=`carthage outdated --use-ssh`
POD_UPDATES=""
CARTHAGE_UPDATES=""
if echo "${POD_OUTDATED}" | grep "No pod updates are available." ; then
echo "cocoapods no updates"
else
POD_UPDATES=`echo "$POD_OUTDATED" | grep '(latest version'`
fi
if echo "${CARTHAGE_OUTDATED}" | grep "All dependencies are up to date." ; then
echo "carthage no updates"
else
CARTHAGE_UPDATES=`echo "$CARTHAGE_OUTDATED" | grep '(Latest'`
fi
if [ ${#CARTHAGE_UPDATES} -eq 0 -a ${#POD_UPDATES} -eq 0 ]; then
echo "No update"
exit 0
fi
if [ ${#CARTHAGE_UPDATES} -eq 0 ]; then
echo "empty"
else
carthage update --platform iOS --use-ssh --new-resolver
fi
if [ ${#POD_UPDATES} -eq 0 ]; then
echo "empty"
else
pod update
fi
if which hub >/dev/null; then
echo "hub installed!"
else
echo "hub not installed..."
brew install hub
fi
CREDENTIAL_FILE="$HOME/.config/git-credential"
mkdir -p $HOME/.config
GH_TOKEN=$GITHUB_ACCESS_TOKEN
GH_USER=$GITHUB_USER_NAME
echo "https://${GH_TOKEN}:@github.com" > $CREDENTIAL_FILE
echo "github.com:
- oauth_token: $GH_TOKEN
user: $GH_USER
protocol: https
" > "$HOME/.config/hub"
git config --global user.name "${GH_USER}"
git config --global user.email "${GH_USER}@users.noreply.github.com"
git config --global credential.helper "store --file=$CREDENTIAL_FILE"
touch pr.txt
echo "Detected outdated dependencies." > pr.txt
BRANCH_NAME="refactor/library_"`date "+%Y-%m-%d_%H-%M-%S"`
git checkout -b $BRANCH_NAME
git add Cartfile.resolved
git add Podfile.lock
if git commit -m "[Auto generated] Update dependencies" ; then
git push origin $BRANCH_NAME
hub pull-request -F pr.txt -b develop
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment