mirror of https://github.com/jacekkow/keycloak-protocol-cas

Updater Bot
2020-03-25 fca7b4d14404bed7d277c1083f17e9ff7bf1b826
commit | author | age
9532f1 1 #!/bin/bash
MP 2 set -e
3
4 function docker_tag_exists() {
07e386 5     REGISTRY_URL="https://quay.io/v2/$1/manifests/$2"
MP 6     curl -fsSLI "$REGISTRY_URL" > /dev/null
9532f1 7 }
MP 8
9 setup_git() {
10     git config --global user.email "updater@travis-ci.org"
11     git config --global user.name "Updater Bot"
12     git remote add origin-auth https://${GH_TOKEN}@github.com/${TRAVIS_REPO_SLUG}.git > /dev/null 2>&1
13 }
14
15 pull_request() {
16     curl -fsSL -H "Authorization: token ${GH_TOKEN}" -X POST -d "{\"head\":\"$1\",\"base\":\"master\",\"title\":\"$2\",\"body\":\"$3\"}" "https://api.github.com/repos/${TRAVIS_REPO_SLUG}/pulls"
17 }
18
19
07e386 20 KEYCLOAK_VERSION=$(mvn versions:display-property-updates -DincludeProperties=keycloak.version | grep "keycloak.version" | sed -nr "s/.*->\s*([0-9]+\.[0-9]+\.[0-9])$/\1/p")
9532f1 21 if [ -z "$KEYCLOAK_VERSION" ]; then
MP 22     echo "No Keycloak update found."
23     exit
24 fi
25 echo "Keycloak version $KEYCLOAK_VERSION available; updating..."
26
27 BRANCH=feature/keycloak-update-$KEYCLOAK_VERSION
28 if git ls-remote -q --exit-code origin $BRANCH; then
29     echo "Branch $BRANCH already exists."
30     exit
31 fi
32
07e386 33 if ! docker_tag_exists keycloak/keycloak $KEYCLOAK_VERSION; then
MP 34     echo "Docker image for Keycloak $KEYCLOAK_VERSION not found, not updating."
9532f1 35     exit
MP 36 fi
37 echo "Found updated docker image, proceeding"
38
39 mvn versions:set -DnewVersion=$KEYCLOAK_VERSION -DgenerateBackupPoms=false
07e386 40 sed -i "s/KEYCLOAK_VERSION=.*/KEYCLOAK_VERSION=$KEYCLOAK_VERSION/" .travis.yml
9532f1 41
MP 42 setup_git
43 git checkout -b $BRANCH
44 git add pom.xml .travis.yml
07e386 45 git commit -m "Update to Keycloak $KEYCLOAK_VERSION"
9532f1 46 git push --quiet --set-upstream origin-auth $BRANCH
MP 47
07e386 48 PR_TITLE="Update to Keycloak $KEYCLOAK_VERSION"
MP 49 PR_BODY="Updates Keycloak dependency, CI test image and project version for Keycloak release $KEYCLOAK_VERSION\\n\\n*(automated pull request after upstream release)*"
9532f1 50 pull_request $BRANCH "$PR_TITLE" "$PR_BODY"
MP 51 echo "Created pull request '$PR_TITLE'"