Skip to content

Commit e174231

Browse files
committed
Polish "Automate Docker update in CI"
See gh-20530
1 parent 4752d7e commit e174231

File tree

5 files changed

+22
-22
lines changed

5 files changed

+22
-22
lines changed

ci/pipeline.yml

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,6 @@ jobs:
189189
- name: detect-docker-updates
190190
plan:
191191
- get: git-repo
192-
resource: git-repo-ci-docker
193192
- get: every-wednesday
194193
trigger: true
195194
- get: spring-boot-ci-image
@@ -199,13 +198,11 @@ jobs:
199198
params:
200199
GITHUB_REPO: spring-boot
201200
GITHUB_ORGANIZATION: spring-projects
202-
GITHUB_PASSWORD: ((github-password))
203-
GITHUB_USERNAME: ((github-username))
204201
ISSUE_TITLE: ((docker-upgrade-issue-title))
205202
image: spring-boot-ci-image
206203
- put: git-repo-ci-docker
207204
params:
208-
repository: docker-updates-git-repo
205+
repository: git-repo-updated
209206
force: true
210207
- task: create-pull-request
211208
file: git-repo/ci/tasks/create-pull-request.yml

ci/scripts/create-pull-request.sh

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,17 @@
11
#!/bin/bash
22
set -e
33

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

ci/scripts/detect-docker-updates.sh

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,20 +18,17 @@ fi
1818
existing_tasks=$( curl -s https://api.github.com/repos/${GITHUB_ORGANIZATION}/${GITHUB_REPO}/pulls\?labels\=type:%20task\&state\=open\&creator\=spring-buildmaster )
1919
existing_upgrade_issues=$( echo "$existing_tasks" | jq -c --arg TITLE "$ISSUE_TITLE" '.[] | select(.title==$TITLE)' )
2020

21+
git clone git-repo git-repo-updated > /dev/null
22+
2123
if [[ ${existing_upgrade_issues} = "" ]]; then
22-
pushd git-repo > /dev/null
23-
popd > /dev/null
24-
git clone git-repo docker-updates-git-repo > /dev/null
25-
pushd docker-updates-git-repo > /dev/null
26-
# Create changes in dedicated branch
27-
branch="ci-docker-$latest_version"
24+
pushd git-repo-updated > /dev/null
2825
git config user.name "Spring Buildmaster" > /dev/null
2926
git config user.email "[email protected]" > /dev/null
30-
git checkout -b "$branch" origin/master > /dev/null
3127
sed -i "s/version=.*/version=\"$latest_version\"/" ci/images/get-docker-url.sh
3228
git add ci/images/get-docker-url.sh > /dev/null
3329
commit_message="Upgrade to Docker $latest_version in CI"
3430
git commit -m "$commit_message" > /dev/null
31+
echo ${commit_message} > commit-details/message
3532
else
3633
echo "Pull request already exists."
3734
fi

ci/tasks/create-pull-request.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
platform: linux
33
inputs:
44
- name: git-repo
5+
- name: commit-details
56
params:
67
BASE_BRANCH:
78
BRANCH:

ci/tasks/detect-docker-updates.yml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,11 @@ platform: linux
33
inputs:
44
- name: git-repo
55
outputs:
6-
- name: docker-updates-git-repo
6+
- name: git-repo-updated
7+
- name: commit-details
78
params:
89
GITHUB_REPO:
910
GITHUB_ORGANIZATION:
10-
GITHUB_PASSWORD:
11-
GITHUB_USERNAME:
1211
ISSUE_TITLE:
1312
run:
1413
path: git-repo/ci/scripts/detect-docker-updates.sh

0 commit comments

Comments
 (0)