Skip to content

Commit a87e6fa

Browse files
committed
Skip update check if pulling failed
1 parent 79797db commit a87e6fa

File tree

1 file changed

+17
-22
lines changed

1 file changed

+17
-22
lines changed

php-build.bash

Lines changed: 17 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,9 @@ then
4444
fi
4545
base_image="${base_image}cli-alpine"
4646
dockerfile="FROM ${base_image}
47-
RUN apk add --update --no-cache bash coreutils git make openssh patch unzip zip"
47+
RUN apk add --update --no-cache bash coreutils git make openssh patch unzip zip
48+
# INI settings to set within Github Action's build runner
49+
RUN echo 'memory_limit=4G' > /usr/local/etc/php/conf.d/php-build.ini"
4850

4951
base_repo="$1"
5052

@@ -73,14 +75,6 @@ do
7375
done
7476
dockerfile_unique="${dockerfile_unique}-${php_build_version}"
7577

76-
dockerfile="${dockerfile}
77-
ADD ./php-build.ini /usr/local/etc/php/conf.d"
78-
79-
cat > ./php-build.ini<< EOF
80-
;INI settings to set within Github Action's build runner
81-
memory_limit=4G
82-
EOF
83-
8478
# Remove illegal characters and make lowercase:
8579
GITHUB_REPOSITORY="${GITHUB_REPOSITORY,,}"
8680
dockerfile_unique="${dockerfile_unique// /_}"
@@ -102,23 +96,24 @@ echo "$docker_tag" > ./docker_tag
10296
echo "Pulling $docker_tag" >> output.log 2>&1
10397

10498
# No need to continue building the image if the pull was successful.
105-
if docker pull "$docker_tag" >> output.log 2>&1;
106-
then
99+
if docker pull "$docker_tag" >> output.log 2>&1; then
107100
# Unless the PHP version has an update...
108101

109102
# Pull latest PHP Docker image so we can check its version.
110103
echo "Pulling $base_image" >> output.log 2>&1
111-
docker pull "$base_image" >> output.log 2>&1
112-
113-
# Check PHP versions of the latest PHP tag and our tag.
114-
base_image_php_version=$(docker run -i "$base_image" php -r "echo PHP_VERSION;")
115-
cached_image_php_version=$(docker run -i "$docker_tag" php -r "echo PHP_VERSION;")
116-
117-
echo "Comparing $cached_image_php_version (cached) to $base_image_php_version (latest)." >> output.log 2>&1
118-
119-
# No need to continue building if our image already exists and PHP is up-to-date.
120-
if [ $cached_image_php_version == $base_image_php_version ];
121-
then
104+
if docker pull "$base_image" >> output.log 2>&1; then
105+
# Check PHP versions of the latest PHP tag and our tag.
106+
base_image_php_version=$(docker run -i "$base_image" php -r "echo PHP_VERSION;")
107+
cached_image_php_version=$(docker run -i "$docker_tag" php -r "echo PHP_VERSION;")
108+
109+
echo "Comparing $cached_image_php_version (cached) to $base_image_php_version (latest)." >> output.log 2>&1
110+
111+
# No need to continue building if our image already exists and PHP is up-to-date.
112+
if [ $cached_image_php_version == $base_image_php_version ]; then
113+
exit
114+
fi
115+
else
116+
echo "Pulling from upstream failed, ignoring update check" >> output.log 2>&1
122117
exit
123118
fi
124119
fi

0 commit comments

Comments
 (0)