Skip to content

Commit 1ea8c7b

Browse files
committed
Fix case when pull request already exists
If a PR with the given title exists, we clone the existing PR branch so that it doesn't get overridden by master. See gh-20530
1 parent 9ef56b4 commit 1ea8c7b

File tree

4 files changed

+23
-19
lines changed

4 files changed

+23
-19
lines changed

ci/pipeline.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,7 @@ jobs:
189189
- name: detect-docker-updates
190190
plan:
191191
- get: git-repo
192+
- get: git-repo-ci-docker
192193
- get: every-wednesday
193194
trigger: true
194195
- get: spring-boot-ci-image

ci/scripts/create-pull-request.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,5 @@ if [[ -f commit-details/message ]]; then
1111
-X \
1212
POST "https://api.github.com/repos/${GITHUB_ORGANIZATION}/${GITHUB_REPO}/pulls" > /dev/null || { echo "Failed to create pull request" >&2; exit 1; }
1313
else
14-
echo "Already up-to-date"
14+
echo "Already up-to-date."
1515
fi

ci/scripts/detect-docker-updates.sh

Lines changed: 20 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,16 @@
11
#!/bin/bash
22

3+
existing_tasks=$( curl -s https://api.github.com/repos/${GITHUB_ORGANIZATION}/${GITHUB_REPO}/pulls\?labels\=type:%20task\&state\=open\&creator\=spring-buildmaster )
4+
existing_upgrade_issues=$( echo "$existing_tasks" | jq -c --arg TITLE "$ISSUE_TITLE" '.[] | select(.title==$TITLE)' )
5+
6+
if [[ ${existing_upgrade_issues} = "" ]]; then
7+
git clone git-repo git-repo-updated > /dev/null
8+
else
9+
git clone git-repo-ci-docker git-repo-updated > /dev/null
10+
echo "Pull request already exists."
11+
exit 0
12+
fi
13+
314
latest_version=$(curl -I -s https://github.com/docker/docker-ce/releases/latest | grep "location:" | awk '{n=split($0, parts, "/"); print substr(parts[n],2);}' | awk '{$1=$1;print}' | tr -d '\r' | tr -d '\n' )
415

516
if [[ $latest_version =~ (beta|rc) ]]; then
@@ -15,21 +26,12 @@ if [[ $current = $latest ]]; then
1526
exit 0;
1627
fi
1728

18-
existing_tasks=$( curl -s https://api.github.com/repos/${GITHUB_ORGANIZATION}/${GITHUB_REPO}/pulls\?labels\=type:%20task\&state\=open\&creator\=spring-buildmaster )
19-
existing_upgrade_issues=$( echo "$existing_tasks" | jq -c --arg TITLE "$ISSUE_TITLE" '.[] | select(.title==$TITLE)' )
20-
21-
git clone git-repo git-repo-updated > /dev/null
22-
23-
if [[ ${existing_upgrade_issues} = "" ]]; then
24-
pushd git-repo-updated > /dev/null
25-
git config user.name "Spring Buildmaster" > /dev/null
26-
git config user.email "[email protected]" > /dev/null
27-
sed -i "s/version=.*/version=\"$latest_version\"/" ci/images/get-docker-url.sh
28-
git add ci/images/get-docker-url.sh > /dev/null
29-
commit_message="Upgrade to Docker $latest_version in CI"
30-
git commit -m "$commit_message" > /dev/null
31-
popd
32-
echo ${commit_message} > commit-details/message
33-
else
34-
echo "Pull request already exists."
35-
fi
29+
pushd git-repo-updated > /dev/null
30+
git config user.name "Spring Buildmaster" > /dev/null
31+
git config user.email "[email protected]" > /dev/null
32+
sed -i "s/version=.*/version=\"$latest_version\"/" ci/images/get-docker-url.sh
33+
git add ci/images/get-docker-url.sh > /dev/null
34+
commit_message="Upgrade to Docker $latest_version in CI"
35+
git commit -m "$commit_message" > /dev/null
36+
popd
37+
echo ${commit_message} > commit-details/message

ci/tasks/detect-docker-updates.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: git-repo-ci-docker
56
outputs:
67
- name: git-repo-updated
78
- name: commit-details

0 commit comments

Comments
 (0)