Polish "Automate Docker update in CI"

See gh-20530
pull/20912/head
Madhura Bhave 5 years ago
parent 4752d7e91a
commit e174231d15

@ -189,7 +189,6 @@ jobs:
- name: detect-docker-updates
plan:
- get: git-repo
resource: git-repo-ci-docker
- get: every-wednesday
trigger: true
- get: spring-boot-ci-image
@ -199,13 +198,11 @@ jobs:
params:
GITHUB_REPO: spring-boot
GITHUB_ORGANIZATION: spring-projects
GITHUB_PASSWORD: ((github-password))
GITHUB_USERNAME: ((github-username))
ISSUE_TITLE: ((docker-upgrade-issue-title))
image: spring-boot-ci-image
- put: git-repo-ci-docker
params:
repository: docker-updates-git-repo
repository: git-repo-updated
force: true
- task: create-pull-request
file: git-repo/ci/tasks/create-pull-request.yml

@ -1,11 +1,17 @@
#!/bin/bash
set -e
curl \
-s \
-u ${GITHUB_USERNAME}:${GITHUB_PASSWORD} \
-H "Content-type:application/json" \
-d "{\"head\":\"${BRANCH}\",\"base\":\"${BASE_BRANCH}\",\"title\":\"${ISSUE_TITLE}\",\"body\":\"\",\"labels\":[\"status: waiting-for-triage\",\"type: task\"]}" \
-f \
-X \
POST "https://api.github.com/repos/${GITHUB_ORGANIZATION}/${GITHUB_REPO}/pulls" > /dev/null || { echo "Failed to create pull request" >&2; exit 1; }
commit_message=$( cat commit-details/message )
if [[ ${commit_message} != "" ]]; then
curl \
-s \
-u ${GITHUB_USERNAME}:${GITHUB_PASSWORD} \
-H "Content-type:application/json" \
-d "{\"head\":\"${BRANCH}\",\"base\":\"${BASE_BRANCH}\",\"title\":\"${ISSUE_TITLE}\",\"body\":\"\",\"labels\":[\"status: waiting-for-triage\",\"type: task\"]}" \
-f \
-X \
POST "https://api.github.com/repos/${GITHUB_ORGANIZATION}/${GITHUB_REPO}/pulls" > /dev/null || { echo "Failed to create pull request" >&2; exit 1; }
else
echo "Already up-to-date"
fi

@ -18,20 +18,17 @@ fi
existing_tasks=$( curl -s https://api.github.com/repos/${GITHUB_ORGANIZATION}/${GITHUB_REPO}/pulls\?labels\=type:%20task\&state\=open\&creator\=spring-buildmaster )
existing_upgrade_issues=$( echo "$existing_tasks" | jq -c --arg TITLE "$ISSUE_TITLE" '.[] | select(.title==$TITLE)' )
git clone git-repo git-repo-updated > /dev/null
if [[ ${existing_upgrade_issues} = "" ]]; then
pushd git-repo > /dev/null
popd > /dev/null
git clone git-repo docker-updates-git-repo > /dev/null
pushd docker-updates-git-repo > /dev/null
# Create changes in dedicated branch
branch="ci-docker-$latest_version"
pushd git-repo-updated > /dev/null
git config user.name "Spring Buildmaster" > /dev/null
git config user.email "buildmaster@springframework.org" > /dev/null
git checkout -b "$branch" origin/master > /dev/null
sed -i "s/version=.*/version=\"$latest_version\"/" ci/images/get-docker-url.sh
git add ci/images/get-docker-url.sh > /dev/null
commit_message="Upgrade to Docker $latest_version in CI"
git commit -m "$commit_message" > /dev/null
echo ${commit_message} > commit-details/message
else
echo "Pull request already exists."
fi

@ -2,6 +2,7 @@
platform: linux
inputs:
- name: git-repo
- name: commit-details
params:
BASE_BRANCH:
BRANCH:

@ -3,12 +3,11 @@ platform: linux
inputs:
- name: git-repo
outputs:
- name: docker-updates-git-repo
- name: git-repo-updated
- name: commit-details
params:
GITHUB_REPO:
GITHUB_ORGANIZATION:
GITHUB_PASSWORD:
GITHUB_USERNAME:
ISSUE_TITLE:
run:
path: git-repo/ci/scripts/detect-docker-updates.sh

Loading…
Cancel
Save