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

@ -1,11 +1,17 @@
#!/bin/bash #!/bin/bash
set -e set -e
curl \ commit_message=$( cat commit-details/message )
-s \
-u ${GITHUB_USERNAME}:${GITHUB_PASSWORD} \ if [[ ${commit_message} != "" ]]; then
-H "Content-type:application/json" \ curl \
-d "{\"head\":\"${BRANCH}\",\"base\":\"${BASE_BRANCH}\",\"title\":\"${ISSUE_TITLE}\",\"body\":\"\",\"labels\":[\"status: waiting-for-triage\",\"type: task\"]}" \ -s \
-f \ -u ${GITHUB_USERNAME}:${GITHUB_PASSWORD} \
-X \ -H "Content-type:application/json" \
POST "https://api.github.com/repos/${GITHUB_ORGANIZATION}/${GITHUB_REPO}/pulls" > /dev/null || { echo "Failed to create pull request" >&2; exit 1; } -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_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)' ) 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 if [[ ${existing_upgrade_issues} = "" ]]; then
pushd git-repo > /dev/null pushd git-repo-updated > /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"
git config user.name "Spring Buildmaster" > /dev/null git config user.name "Spring Buildmaster" > /dev/null
git config user.email "buildmaster@springframework.org" > /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 sed -i "s/version=.*/version=\"$latest_version\"/" ci/images/get-docker-url.sh
git add ci/images/get-docker-url.sh > /dev/null git add ci/images/get-docker-url.sh > /dev/null
commit_message="Upgrade to Docker $latest_version in CI" commit_message="Upgrade to Docker $latest_version in CI"
git commit -m "$commit_message" > /dev/null git commit -m "$commit_message" > /dev/null
echo ${commit_message} > commit-details/message
else else
echo "Pull request already exists." echo "Pull request already exists."
fi fi

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

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

Loading…
Cancel
Save