-
Notifications
You must be signed in to change notification settings - Fork 41.5k
Automate Docker updates in CI #20530
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
#!/bin/bash | ||
set -e | ||
|
||
version="19.03.7" | ||
echo "https://download.docker.com/linux/static/stable/x86_64/docker-$version.tgz"; |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,6 +27,14 @@ resources: | |
username: ((github-username)) | ||
password: ((github-password)) | ||
branch: ((branch)) | ||
- name: git-repo-ci-docker | ||
type: git | ||
icon: github-circle | ||
source: | ||
uri: ((github-repo)) | ||
username: ((github-username)) | ||
password: ((github-password)) | ||
branch: ci-docker-((branch)) | ||
- name: git-repo-windows | ||
type: git | ||
source: | ||
|
@@ -209,6 +217,37 @@ jobs: | |
GITHUB_PASSWORD: ((github-password)) | ||
GITHUB_USERNAME: ((github-username)) | ||
image: spring-boot-ci-image | ||
- name: detect-docker-updates | ||
plan: | ||
- get: git-repo | ||
resource: git-repo-ci-docker | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I was wondering if that should point to the new resource. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think it should point to the new resource. We will only use the new resource to |
||
- get: every-wednesday | ||
trigger: true | ||
- get: spring-boot-ci-image | ||
- do: | ||
- task: detect-docker-updates | ||
file: git-repo/ci/tasks/detect-docker-updates.yml | ||
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 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Where is the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, that's correct. You do have it as an output in |
||
force: true | ||
- task: create-pull-request | ||
file: git-repo/ci/tasks/create-pull-request.yml | ||
params: | ||
BASE_BRANCH: ((branch)) | ||
BRANCH: ci-docker-((branch)) | ||
GITHUB_REPO: spring-boot | ||
GITHUB_ORGANIZATION: spring-projects | ||
GITHUB_PASSWORD: ((github-password)) | ||
GITHUB_USERNAME: ((github-username)) | ||
ISSUE_TITLE: ((docker-upgrade-issue-title)) | ||
- name: build | ||
serial: true | ||
public: true | ||
|
@@ -595,6 +634,6 @@ groups: | |
- name: "Release" | ||
jobs: ["stage-milestone", "stage-rc", "stage-release", "promote-milestone", "promote-rc", "promote-release", "sync-to-maven-central"] | ||
- name: "CI Images" | ||
jobs: ["build-spring-boot-ci-images", "detect-jdk-updates", "detect-ubuntu-image-updates"] | ||
jobs: ["build-spring-boot-ci-images", "detect-docker-updates", "detect-jdk-updates", "detect-ubuntu-image-updates"] | ||
- name: "Build Pull Requests" | ||
jobs: ["build-pull-requests"] |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#!/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; } |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
#!/bin/bash | ||
|
||
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' ) | ||
|
||
if [[ $latest_version =~ (beta|rc) ]]; then | ||
echo "Skip pre-release versions" | ||
exit 0; | ||
fi | ||
|
||
latest="https://download.docker.com/linux/static/stable/x86_64/docker-$latest_version.tgz" | ||
current=$( git-repo/ci/images/get-docker-url.sh ) | ||
|
||
if [[ $current = $latest ]]; then | ||
echo "Already up-to-date" | ||
exit 0; | ||
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)' ) | ||
|
||
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" | ||
git config user.name "Spring Buildmaster" > /dev/null | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We'd need to |
||
git config user.email "buildmaster@springframework.org" > /dev/null | ||
git checkout -b "$branch" origin/master > /dev/null | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not sure if this will work in the Concourse setup as I don't know if we have a real repository there. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It will work. |
||
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 | ||
else | ||
echo "Pull request already exists." | ||
fi |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
--- | ||
platform: linux | ||
inputs: | ||
- name: git-repo | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm wondering if this need to be a different input - e.g. the docker git resource in this case. Which makes it less generic somehow. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For this task, it only uses the |
||
params: | ||
BASE_BRANCH: | ||
BRANCH: | ||
GITHUB_REPO: | ||
GITHUB_ORGANIZATION: | ||
GITHUB_PASSWORD: | ||
GITHUB_USERNAME: | ||
ISSUE_TITLE: | ||
run: | ||
path: git-repo/ci/scripts/create-pull-request.sh |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
--- | ||
platform: linux | ||
inputs: | ||
- name: git-repo | ||
outputs: | ||
- name: docker-updates-git-repo | ||
params: | ||
GITHUB_REPO: | ||
GITHUB_ORGANIZATION: | ||
GITHUB_PASSWORD: | ||
GITHUB_USERNAME: | ||
ISSUE_TITLE: | ||
run: | ||
path: git-repo/ci/scripts/detect-docker-updates.sh |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this working if the branch doesn't exist?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, we need to create a long-running branch beforehand. I don't know if there's a way to create branches on the fly in concourse.