Skip to content

Commit 79797db

Browse files
author
Greg Bowler
authored
Merge pull request #17 from westy92/update-php-versions
Allow PHP Versions to Update
2 parents 9d8e7cb + 42c9f3e commit 79797db

File tree

2 files changed

+23
-8
lines changed

2 files changed

+23
-8
lines changed

Diff for: README.md

+3-4
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Fast builds for repositories using php-actions.
1+
# Fast builds for repositories using php-actions
22

33
v1 of this repository used a totally different architecture and had different goals to the current version. Previously, a customised Dockerfile was used as the base for all php-actions repositories, but now php-actions workflows run as [composite run steps][composite], building a customised docker image per-application, based off the official PHP script.
44

@@ -25,7 +25,7 @@ Choosing the PHP version
2525

2626
The `ACTION_PHP_VERSION` environment variable must be passed to the composite run step. This string must match any of the [officially supported PHP version numbers][tag-list] (version number only, with no derivative text, e.g. `8.0.1` or `8` rather than `8-cli`).
2727

28-
The official Alpine CLI build of the requested version will be used as the image's base.
28+
The official Alpine CLI build of the requested version will be used as the image's base.
2929

3030
Enabling/disabling extensions
3131
-----------------------------
@@ -46,7 +46,7 @@ Version caching php-build
4646

4747
This repo, `php-build` shouldn't change very regularly, but when it does, the entire build pipeline of dependent repositories will need refreshing. This is done by adding the version of `php-build` to the end of build package names. When a new release is made that affects php-build functionality, the variable at the top of `php-build.bash` can be updated to invalidate any caches.
4848

49-
Within other repositories that use `php-build`, they can refer to the specific version of the script by addressing its git commit hash. For example: https://raw.githubusercontent.com/php-actions/php-build/27be075494ae8a9bc0d10deb408e37b197986b8a/php-build.bash
49+
Within other repositories that use `php-build`, they can refer to the specific version of the script by addressing its git commit hash. For example: <https://raw.githubusercontent.com/php-actions/php-build/27be075494ae8a9bc0d10deb408e37b197986b8a/php-build.bash>
5050

5151
***
5252

@@ -57,5 +57,4 @@ If you found this repository helpful, please consider [sponsoring the developer]
5757
[tag-list]: https://github.com/docker-library/docs/blob/master/php/README.md#supported-tags-and-respective-dockerfile-links
5858
[mlocati]: https://github.com/mlocati/docker-php-extension-installer
5959
[mlocati-readme]: https://github.com/mlocati/docker-php-extension-installer#supported-php-extensions
60-
[issues]: https://github.com/php-actions/php-build/issues
6160
[sponsor]: https://github.com/sponsors/g105b

Diff for: php-build.bash

100644100755
+20-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/bin/bash
22
set -e
33

4-
php_build_version="build2.1.1"
4+
php_build_version="build2.2.1"
55

66
# Check for required variables:
77
if [ "$#" -lt 1 ]; then
@@ -88,8 +88,8 @@ dockerfile_unique="${dockerfile_unique,,}"
8888
repo_without_org=$(echo "$GITHUB_REPOSITORY" | sed "s/[^\/]*\///")
8989

9090
# This tag will be used to identify the built dockerfile. Once it is built,
91-
# it should not need to be built again, so after the first Github Actions run
92-
# the build should be very quick.
91+
# it should not need to be built again unless there is a PHP update, so after
92+
# the first Github Actions run the build should be very quick.
9393
# Note: The GITHUB_REPOSITORY is the repo where the action is running, nothing
9494
# to do with the php-actions organisation. This means that the image is pushed
9595
# onto a user's Github profile (currently not shared between other users).
@@ -104,7 +104,23 @@ echo "Pulling $docker_tag" >> output.log 2>&1
104104
# No need to continue building the image if the pull was successful.
105105
if docker pull "$docker_tag" >> output.log 2>&1;
106106
then
107-
exit
107+
# Unless the PHP version has an update...
108+
109+
# Pull latest PHP Docker image so we can check its version.
110+
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
122+
exit
123+
fi
108124
fi
109125

110126
echo "Building PHP $ACTION_PHP_VERSION with extensions: $ACTION_PHP_EXTENSIONS ..."

0 commit comments

Comments
 (0)