Skip to content

Commit ec0577b

Browse files
authored
Merge pull request #28 from dhsathiya/feature/hosts-WP-version
Feature: Different WP_VERSION for each branch
2 parents 3733951 + 988015f commit ec0577b

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ jobs:
3333
```
3434
3535
3. Create `SSH_PRIVATE_KEY` secret using [GitHub Action's Secret](https://developer.github.com/actions/creating-workflows/storing-secrets) and store the private key that you use use to ssh to server(s) defined in `hosts.yml`.
36-
4. Create `.github/hosts.yml` inventory file, based on [Deployer inventory file](https://deployer.org/docs/hosts.html#inventory-file) format. Make sure you explictly define GitHub branch mapping. Only the GitHub branches mapped in `hosts.yml` will be deployed, rest will be filtered out. Here is a sample [hosts.yml](https://github.com/rtCamp/wordpress-skeleton/blob/master/.github/hosts.yml).
36+
4. Create `.github/hosts.yml` inventory file, based on [Deployer inventory file](https://deployer.org/docs/hosts.html#inventory-file) format. Make sure you explictly define GitHub branch mapping. Only the GitHub branches mapped in `hosts.yml` will be deployed, rest will be filtered out. Here is a sample [hosts.yml](https://github.com/rtCamp/wordpress-skeleton/blob/main/.github/hosts.yml).
3737

3838

3939
## Environment Variables
@@ -43,7 +43,7 @@ This GitHub action's behavior can be customized using following environment vari
4343
Variable | Default | Possible Values | Purpose
4444
------------------|---------|-----------------------------|----------------------------------------------------
4545
`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.
46-
`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.
46+
`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_VERSION defined in hosts.yml will have higher priority than one defined in workflow file.
4747
`WP_MINOR_UPDATE` | null | `true` / `false` | If set to `true`, latest minor version of `WP_VERSION` will be taken.
4848
`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.)
4949
`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)

main.sh

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,15 @@ function setup_wordpress_files() {
166166
cd "$HTDOCS"
167167
export build_root="$(pwd)"
168168

169-
WP_VERSION=${WP_VERSION:-"latest"}
169+
hosts_wp_version=$(cat "$hosts_file" | shyaml get-value "$GITHUB_BRANCH.WP_VERSION" 2> /dev/null)
170+
171+
# Check if WP_VERSION is already defined in hosts.yml
172+
# Priority: 1. hosts.yml, 2. workflow file, else use latest
173+
if [[ -n $hosts_wp_version ]]; then
174+
WP_VERSION="$hosts_wp_version"
175+
elif [[ -z $WP_VERSION ]]; then
176+
WP_VERSION="latest"
177+
fi
170178

171179
if [[ "$WP_MINOR_UPDATE" == "true" ]] && [[ "$WP_VERSION" != "latest" ]]; then
172180
LATEST_MINOR_VERSION=$(\

0 commit comments

Comments
 (0)