-
Notifications
You must be signed in to change notification settings - Fork 140
/
Copy pathdocker-update.yml
54 lines (49 loc) · 2.12 KB
/
docker-update.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
---
steps:
- label: "Docker build and push"
agents:
- "queue=default"
plugins:
docker#v3.8.0:
always-pull: true
environment:
- ANDROID_HOME
- ANDROID_NDK_HOME
- BUILDKITE_ARTIFACT_UPLOAD_DESTINATION
image: gcr.io/bazel-public/ubuntu1804-java11
network: host
privileged: true
propagate-environment: true
propagate-uid-gid: true
shell: ["/bin/bash", "-e", "-c"]
volumes:
- "/etc/group:/etc/group:ro"
- "/etc/passwd:/etc/passwd:ro"
- "/etc/shadow:/etc/shadow:ro"
- "/opt/android-ndk-r15c:/opt/android-ndk-r15c:ro"
- "/opt/android-sdk-linux:/opt/android-sdk-linux:ro"
- "/var/lib/buildkite-agent:/var/lib/buildkite-agent"
- "/var/lib/gitmirrors:/var/lib/gitmirrors:ro"
- "/var/run/docker.sock:/var/run/docker.sock"
command: |
echo "+++ Checking out Git branch"
git fetch origin ${BUILDKITE_BRANCH}
git checkout ${BUILDKITE_BRANCH}
echo "release_name = \"\$release_name\""
version=$(echo $release_name | sed 's/release-//g')
echo "version = \"\$version\""
echo "+++ Building the docker container"
./bazel/oci/build.sh gcr.io/bazel-public/bazel \${version}
echo "+++ Pushing the docker container to gcr.io/bazel-public/bazel"
docker push gcr.io/bazel-public/bazel:\${version}
echo "+++ Checking if latest release"
latest_release_url=$(curl -Ls -o /dev/null -w %{url_effective} https://github.com/bazelbuild/bazel/releases/latest)
latest_release_tag=$(basename \${latest_release_url})
echo "latest_release_tag = \"\$latest_release_tag\""
if [[ \"\$version\" == \"\$latest_release_tag\" ]]; then
echo "+++ Updating the latest tag"
image_id=$(docker image list gcr.io/bazel-public/bazel:\${version} --format \"{{.ID}}\")
image_id=$(echo \${image_id} | tr -d '"')
docker tag \${image_id} gcr.io/bazel-public/bazel:latest
docker push gcr.io/bazel-public/bazel:latest
fi