Skip to content

Commit 99967b8

Browse files
committed
Added dockerfiles updating script
Signed-off-by: bharathappali <[email protected]>
1 parent 8e5550b commit 99967b8

File tree

3 files changed

+138
-2
lines changed

3 files changed

+138
-2
lines changed

update_all.sh

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,11 @@ set -o pipefail
1717
# shellcheck source=common_functions.sh
1818
source ./common_functions.sh
1919

20+
if [ -n "$1" ]; then
21+
build_arg="$1"
22+
fi
23+
24+
2025
for ver in ${supported_versions}
2126
do
2227
# Cleanup any old containers and images
@@ -32,7 +37,7 @@ do
3237
echo " "
3338
echo "==============================================================================="
3439
# Generate the Dockerfiles for the unofficial images.
35-
./update_multiarch.sh "${ver}"
40+
./update_multiarch.sh "${ver}" "${build_arg}"
3641

3742
# hotspot.config and openj9.config now only contain the unofficial image list.
3843
# hotspot-official.config and openj9-official.config contain the officially supported list.
@@ -41,7 +46,7 @@ do
4146
cp config/openj9-official.config config/openj9.config
4247

4348
# Now generate the Dockerfiles for the official images.
44-
./update_multiarch.sh "${ver}"
49+
./update_multiarch.sh "${ver}" "${build_arg}"
4550

4651
# Restore the original files.
4752
git checkout config/hotspot.config config/openj9.config

update_dockerfiles_on_merge.sh

Lines changed: 125 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,125 @@
1+
#!/bin/bash
2+
3+
source common_functions.sh
4+
5+
REMOTE_UPSTREAM="upstream"
6+
BRANCH_NAME="automated-branch-for-dockerfiles"
7+
8+
function proceed_to_update() {
9+
UPSTREAM=$(cat .git/config | grep -m 1 -B 1 "https://github.com/AdoptOpenJDK/openjdk-docker" | head -n 1 | cut -d '"' -f 2)
10+
if [ -z $UPSTREAM ]; then
11+
if cat .git/config | grep -Fxq "[remote \"upstream\"]"; then
12+
git remote add temp-upstream https://github.com/AdoptOpenJDK/openjdk-docker
13+
REMOTE_UPSTREAM="temp-upstream"
14+
else
15+
git remote add upstream https://github.com/AdoptOpenJDK/openjdk-docker
16+
fi
17+
else
18+
REMOTE_UPSTREAM="$UPSTREAM"
19+
fi
20+
git checkout master
21+
git fetch ${REMOTE_UPSTREAM}
22+
git merge ${REMOTE_UPSTREAM}/master
23+
local CHECK_LOCAL=$(git branch --list ${BRANCH_NAME})
24+
if [[ -z ${CHECK_LOCAL} ]]; then
25+
git checkout -b ${BRANCH_NAME}
26+
else
27+
git branch -D ${BRANCH_NAME}
28+
git checkout -b ${BRANCH_NAME}
29+
fi
30+
source update_all.sh releases
31+
git add ${supported_versions}
32+
git commit -m "$(date '+%d-%m-%Y %H:%M:%S') : Auto-updating dockerfiles for PR #${PR_NUM}" -s
33+
git push -f origin ${BRANCH_NAME}
34+
echo "Please raise a PR to AdoptOpenJDK/openjdk-docker master from branch ${BRANCH_NAME}"
35+
echo "Exiting."
36+
exit 0
37+
}
38+
39+
function script_usage() {
40+
echo "USAGE:"
41+
echo ""
42+
echo " update_dockerfiles_on_merge.sh <Pull request id/number >"
43+
echo ""
44+
echo "EXAMPLE:"
45+
echo ""
46+
echo "To update the dockerfiles if the PR 444 is merged, you need to ENTER the following command :"
47+
echo ""
48+
echo " ./update_dockerfiles_on_merge.sh 444"
49+
echo ""
50+
}
51+
52+
53+
function check_for_result() {
54+
local RESULT=$(curl -fs https://api.github.com/repos/AdoptOpenJDK/openjdk-docker/pulls/${PR_NUM} | grep "\"merged\"" | tr ',' ' ' | tr -d " " | cut -d ":" -f 2)
55+
56+
if [ -z $RESULT ]; then
57+
echo ""
58+
echo "INVALID PR. PLEASE CHECK AGAIN AND RUN THE SCRIPT"
59+
echo ""
60+
exit 1
61+
fi
62+
63+
local ITERATION=1
64+
while [ "$RESULT" == "false" ]
65+
do
66+
echo "TRAIL : $ITERATION - PR Haven't been merged, Retrying after 1 minute"
67+
ITERATION=$(expr $ITERATION + 1)
68+
sleep 60
69+
RESULT=$(curl -fs https://api.github.com/repos/AdoptOpenJDK/openjdk-docker/pulls/${PR_NUM} | grep "\"merged\"" | tr ',' ' ' | tr -d " " | cut -d ":" -f 2)
70+
done
71+
72+
if [ "$RESULT" != "true" ]; then
73+
echo "Unexpected Error. Exiting"
74+
exit 1
75+
fi
76+
}
77+
78+
if [ "$#" -ne 1 ]; then
79+
echo "You must enter only the PR number as an argument. See the usage below."
80+
echo ""
81+
script_usage
82+
exit 1
83+
fi
84+
85+
PR_NUM=$1
86+
87+
NUM_REGEX='^[0-9]+$'
88+
89+
if ! [[ $PR_NUM =~ $NUM_REGEX ]] ; then
90+
echo "Expected PR number as arg. See the usage below."
91+
echo ""
92+
script_usage
93+
exit 1
94+
fi
95+
96+
NOCOLOR='\033[0m' # No Color - Color Reset
97+
98+
# Normal Colors
99+
RED='\033[0;31m'
100+
GREEN='\033[0;32m'
101+
BLUE='\033[0;34m'
102+
CYAN='\033[0;36m'
103+
104+
# Bold Colors
105+
BRED='\033[1;31m'
106+
BGREEN='\033[1;32m'
107+
BBLUE='\033[1;34m'
108+
BCYAN='\033[1;36m'
109+
110+
echo ""
111+
echo -e "This script calls the ${BBLUE}'update_all.sh'${NOCOLOR} to update the dockerfiles"
112+
echo ""
113+
echo -e "It pulls ${BCYAN}AdoptOpenJDK/openjdk-docker${NOCOLOR} ${BLUE}master${NOCOLOR} branch latest changes and"
114+
echo -e "merges local master. Later creates a new branch to update dockerfiles"
115+
echo ""
116+
echo -e "${BGREEN}New branch name${NOCOLOR} : ${BLUE}${BRANCH_NAME}${NOCOLOR}"
117+
echo ""
118+
echo -e "If the branch exists, it ${RED}deletes${NOCOLOR} existing branch and creates new"
119+
echo -e "branch which is even with master"
120+
echo ""
121+
echo -e "${BRED}CAUTION${NOCOLOR} : Please run this script after saving your work (commiting) as ${RED}it may mess up your changes${NOCOLOR}."
122+
echo ""
123+
echo ""
124+
check_for_result
125+
proceed_to_update

update_multiarch.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ if [ -n "$1" ]; then
2525
set_version "$1"
2626
fi
2727

28+
build_arg="$2"
29+
2830
# Set the OSes that will be built on based on the current arch
2931
set_arch_os
3032

@@ -43,6 +45,10 @@ do
4345
btypes=$(parse_vm_entry "${vm}" "${version}" "${package}" "${os}" "Type:")
4446
dir=$(parse_vm_entry "${vm}" "${version}" "${package}" "${os}" "Directory:")
4547

48+
if [ ! -z "${build_arg}" ]; then
49+
builds="${build_arg}"
50+
fi
51+
4652
for build in ${builds}
4753
do
4854
echo "Getting latest shasum info for [ ${version} ${vm} ${package} ${build} ]"

0 commit comments

Comments
 (0)