Skip to content

Automatic minor version upgrade via WP_MINOR_UPDATE #25

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jun 1, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,9 @@ This GitHub action's behavior can be customized using following environment vari

Variable | Default | Possible Values | Purpose
------------------|---------|-----------------------------|----------------------------------------------------
`MU_PLUGINS_URL` | null | vip, any git repo url | If value is `vip`, then action will clone [VIP's MU plugins](https://github.com/Automattic/vip-mu-plugins-public) as `mu-plugins` folder. If you want to specifiy a non-VIP mu-plugins repo, you can provide a publicly accessible mu-plugins repo URL as the value.
`MU_PLUGINS_URL` | null | vip, any git repo url | If value is `vip`, then action will clone [VIP's MU plugins](https://github.com/Automattic/vip-mu-plugins-public) as `mu-plugins` folder. If you want to specifiy a non-VIP mu-plugins repo, you can provide a publicly accessible mu-plugins repo URL as the value.
`WP_VERSION` | latest | Any valid WordPress version | If you specify a WordPress version, then that speicifc WordPress version will be downloaded, instead of latest WordPress version.
`WP_MINOR_UPDATE` | null | `true` / `false` | If set to `true`, latest minor version of `WP_VERSION` will be taken.
`JUMPHOST_SERVER` | null | Hostname/IP address of the jumphost server | If the deployment server is not directly accessible, and needs a jumphost, then this method should be used. (Note: The `SSH_PRIVATE_KEY` env variable should have access to the jumphost as well as deployment server for this to work. Also, this method does not work with vault.)
`SUBMODULE_DEPLOY_KEY` | null | Read access deploy key created in the submodule repo's deploy keys. | Only required for privated submodule repo. For now only one private submodule deploy key is allowed. All public submodules in repo will be fetched by default without the need of this env variable. (To create a deploy key go to: Settings > Deploy Keys > Add deploy key)

Expand Down
15 changes: 15 additions & 0 deletions main.sh
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,21 @@ function setup_wordpress_files() {
export build_root="$(pwd)"

WP_VERSION=${WP_VERSION:-"latest"}

if [[ "$WP_MINOR_UPDATE" == "true" ]] && [[ "$WP_VERSION" != "latest" ]]; then
LATEST_MINOR_VERSION=$(\
curl -s "https://api.wordpress.org/core/version-check/1.7/?version=$WP_VERSION" | \
jq -r '[.offers[]|select(.response=="autoupdate")][-1].version'
)
MAJOR_DOT_MINOR=$(echo "$WP_VERSION" | cut -c1-3)
if [[ "$LATEST_MINOR_VERSION" == "$MAJOR_DOT_MINOR"* ]]; then
WP_VERSION="$LATEST_MINOR_VERSION"
echo "Using $LATEST_MINOR_VERSION as the latest minor version."
else
echo "$WP_VERSION is the latest minor version."
fi
fi

wp core download --version="$WP_VERSION" --allow-root

rm -r wp-content/
Expand Down