forked from openshift/os
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtag-final-image.sh
executable file
·26 lines (21 loc) · 1.07 KB
/
tag-final-image.sh
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
#!/bin/bash
# This script performs the following tasks:
#
# 1. Reads the jobspec to get the active branch so we know what tag
# to use.
#
# 2. Tags the image tagged with the Prow build ID to one of our
# well-known tags (e.g., master, 4.11, latest, etc.)
set -euo pipefail
# We can't use PULL_BASE_REF or OPENSHIFT_BUILD_REFERENCE to get the
# branch since this is a periodic job which originates from
# openshift/release, not the openshift/os repository. We then strip
# release- from the branch name so we're left with the number (e.g.,
# release-4.11 -> 4.11).
BRANCH="$(echo "$JOB_SPEC" | jq -r '.extra_refs[0].base_ref | sub("release-"; "")')"
export REGISTRY_AUTH_FILE="$SHARED_DIR/dockercfg.json"
skopeo copy "docker://registry.ci.openshift.org/rhcos-devel/rhel-coreos:$BUILD_ID" "docker://registry.ci.openshift.org/rhcos-devel/rhel-coreos:$BRANCH"
# Only push latest tag on master branch
if [[ "$BRANCH" == "master" ]]; then
skopeo copy "docker://registry.ci.openshift.org/rhcos-devel/rhel-coreos:$BUILD_ID" "docker://registry.ci.openshift.org/rhcos-devel/rhel-coreos:latest"
fi