diff --git a/README.md b/README.md index e686fb7..67589ef 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# Fast builds for repositories using php-actions. +# Fast builds for repositories using php-actions 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. @@ -25,7 +25,7 @@ Choosing the PHP version 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`). -The official Alpine CLI build of the requested version will be used as the image's base. +The official Alpine CLI build of the requested version will be used as the image's base. Enabling/disabling extensions ----------------------------- @@ -46,7 +46,7 @@ Version caching php-build 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. -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 +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: *** @@ -57,5 +57,4 @@ If you found this repository helpful, please consider [sponsoring the developer] [tag-list]: https://github.com/docker-library/docs/blob/master/php/README.md#supported-tags-and-respective-dockerfile-links [mlocati]: https://github.com/mlocati/docker-php-extension-installer [mlocati-readme]: https://github.com/mlocati/docker-php-extension-installer#supported-php-extensions -[issues]: https://github.com/php-actions/php-build/issues [sponsor]: https://github.com/sponsors/g105b diff --git a/php-build.bash b/php-build.bash old mode 100644 new mode 100755 index b977aca..165d252 --- a/php-build.bash +++ b/php-build.bash @@ -1,7 +1,7 @@ #!/bin/bash set -e -php_build_version="build2.1.1" +php_build_version="build2.2.1" # Check for required variables: if [ "$#" -lt 1 ]; then @@ -88,8 +88,8 @@ dockerfile_unique="${dockerfile_unique,,}" repo_without_org=$(echo "$GITHUB_REPOSITORY" | sed "s/[^\/]*\///") # This tag will be used to identify the built dockerfile. Once it is built, -# it should not need to be built again, so after the first Github Actions run -# the build should be very quick. +# it should not need to be built again unless there is a PHP update, so after +# the first Github Actions run the build should be very quick. # Note: The GITHUB_REPOSITORY is the repo where the action is running, nothing # to do with the php-actions organisation. This means that the image is pushed # onto a user's Github profile (currently not shared between other users). @@ -104,7 +104,23 @@ echo "Pulling $docker_tag" >> output.log 2>&1 # No need to continue building the image if the pull was successful. if docker pull "$docker_tag" >> output.log 2>&1; then - exit + # Unless the PHP version has an update... + + # Pull latest PHP Docker image so we can check its version. + echo "Pulling $base_image" >> output.log 2>&1 + docker pull "$base_image" >> output.log 2>&1 + + # Check PHP versions of the latest PHP tag and our tag. + base_image_php_version=$(docker run -i "$base_image" php -r "echo PHP_VERSION;") + cached_image_php_version=$(docker run -i "$docker_tag" php -r "echo PHP_VERSION;") + + echo "Comparing $cached_image_php_version (cached) to $base_image_php_version (latest)." >> output.log 2>&1 + + # No need to continue building if our image already exists and PHP is up-to-date. + if [ $cached_image_php_version == $base_image_php_version ]; + then + exit + fi fi echo "Building PHP $ACTION_PHP_VERSION with extensions: $ACTION_PHP_EXTENSIONS ..."