Skip to content

Commit d0019cd

Browse files
committed
Merge pull request #20355 from dreis2211
* pr/20355: Automate Ubuntu base image upgrade Closes gh-20355
2 parents 3df4462 + 4136300 commit d0019cd

File tree

3 files changed

+55
-1
lines changed

3 files changed

+55
-1
lines changed

ci/pipeline.yml

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,21 @@ jobs:
163163
GITHUB_USERNAME: ((github-username))
164164
JDK_VERSION: java11
165165
image: spring-boot-ci-image
166+
- name: detect-ubuntu-image-updates
167+
plan:
168+
- get: git-repo
169+
- get: every-wednesday
170+
trigger: true
171+
- get: spring-boot-ci-image
172+
- do:
173+
- task: detect-ubuntu-image-updates
174+
file: git-repo/ci/tasks/detect-ubuntu-image-updates.yml
175+
params:
176+
GITHUB_REPO: spring-boot
177+
GITHUB_ORGANIZATION: spring-projects
178+
GITHUB_PASSWORD: ((github-password))
179+
GITHUB_USERNAME: ((github-username))
180+
image: spring-boot-ci-image
166181
- name: build
167182
serial: true
168183
public: true
@@ -525,6 +540,6 @@ groups:
525540
- name: "Release"
526541
jobs: ["stage-milestone", "stage-rc", "stage-release", "promote-milestone", "promote-rc", "promote-release", "sync-to-maven-central"]
527542
- name: "CI Images"
528-
jobs: ["build-spring-boot-ci-images", "detect-jdk-updates"]
543+
jobs: ["build-spring-boot-ci-images", "detect-jdk-updates", "detect-ubuntu-image-updates"]
529544
- name: "Build Pull Requests"
530545
jobs: ["build-pull-requests"]
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
#!/bin/bash
2+
3+
ISSUE_TITLE="Upgrade Ubuntu version in CI images"
4+
5+
ubuntu="bionic"
6+
latest=$( curl -s "https://partner-images.canonical.com/core/$ubuntu/current/unpacked/build-info.txt" | awk '{split($0, parts, "="); print parts[2]}' )
7+
current=$( grep "ubuntu:$ubuntu" git-repo/ci/images/spring-boot-ci-image/Dockerfile | awk '{split($0, parts, "-"); print parts[2]}' )
8+
9+
if [[ $current = $latest ]]; then
10+
echo "Already up-to-date"
11+
exit 0;
12+
fi
13+
14+
existing_tasks=$( curl -s https://api.github.com/repos/${GITHUB_ORGANIZATION}/${GITHUB_REPO}/issues\?labels\=type:%20task\&state\=open\&creator\=spring-buildmaster )
15+
existing_upgrade_issues=$( echo "$existing_tasks" | jq -c --arg TITLE "$ISSUE_TITLE" '.[] | select(.title==$TITLE)' )
16+
17+
if [[ ${existing_upgrade_issues} = "" ]]; then
18+
curl \
19+
-s \
20+
-u ${GITHUB_USERNAME}:${GITHUB_PASSWORD} \
21+
-H "Content-type:application/json" \
22+
-d "{\"title\":\"${ISSUE_TITLE}\",\"body\": \"Upgrade to ubuntu:${ubuntu}-${latest}\",\"labels\":[\"status: waiting-for-triage\",\"type: task\"]}" \
23+
-f \
24+
-X \
25+
POST "https://api.github.com/repos/${GITHUB_ORGANIZATION}/${GITHUB_REPO}/issues" > /dev/null || { echo "Failed to create issue" >&2; exit 1; }
26+
else
27+
echo "Issue already exists."
28+
fi
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
---
2+
platform: linux
3+
inputs:
4+
- name: git-repo
5+
params:
6+
GITHUB_REPO:
7+
GITHUB_ORGANIZATION:
8+
GITHUB_PASSWORD:
9+
GITHUB_USERNAME:
10+
run:
11+
path: git-repo/ci/scripts/detect-ubuntu-image-updates.sh

0 commit comments

Comments
 (0)