Skip to content

Fix: block emails only when true #43

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 4 commits into from
Jul 14, 2023
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
35 changes: 17 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,15 +54,15 @@ jobs:
|---------------|---------|----------------------------------------------------------------|--------------------------------|
| `user` | null | valid username. eg: `root` | Username for ssh. |
| `deploy_path` | null | valid path. eg: `/opt/easyengine/sites/example.com/app/htdocs` | path where action will deploy. |
| `hostname` | null | hostname. eg: `example.com` | hostname for ssh. |
| `hostname` | null | hostname/ip. eg: `example.com` | hostname for ssh. |


### Optional

| Variable | Default | Possible Values | Description |
|---------------------------------|------------------|-------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `block_emails` | null | true | If set to true, this will enable email blocking functionality. |
| `block_emails_plugin_path` | null | Accept relative path from wp-content directory, eg: `custom-mu-plugins` | If you have set the `MU_PLUGIN_DIR` constant in your wp-config.php file to specify a custom path for mu-plugins, you can use this variable to install Block Emails into your custom mu-plugins directory. |
| `block_emails` | null | `true`/`false` | If set to true, this will enable email blocking functionality. |
| `block_emails_plugin_path` | null | Accept relative path from wp-content directory, eg: `custom-mu-plugins` | If you have set the `MU_PLUGIN_DIR` constant in your wp-config.php file to specify a custom path for mu-plugins, you can use this variable to install Block Emails into your custom mu-plugins directory. |
| `block_emails_plugin_file_name` | 000-block-emails | String without the .php extension. | If you wish to modify the loading position of this plugin within the mu-plugins loading phase. |
| `WP_VERSION` | null | Any valid WordPress version | If you specify a WordPress version, then that speicifc WordPress version will be downloaded, instead of latest WordPress version. **Note:** Please use double quotes while giving value to this variable. This will have higher priority then the one defined in workflow file. |

Expand All @@ -71,21 +71,20 @@ jobs:

This GitHub action's behavior can be customized using following environment variables:

| 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. |
| `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. **Note:** Please use double quotes while giving value to this variable. Also, `WP_VERSION`, if defined in hosts.yml will have higher priority then the one defined in workflow file. |
| `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) |
| `SKIP_WP_TASKS` | null | `true`/`false` | If set to `true`, WordPress specific deplyment tasks will skipped. |
| `PHP_VERSION` | 7.4 | Valid PHP version | Determines the cachetool version compatible to use for purging opcache. |
| `NPM_VERSION` | null | Valid NPM Version | NPM Version. If not specified, latest version will be used. |
| `NODE_VERSION` | null | Valid Node Version | If not specified, default version built into action will be used. |
| `NODE_BUILD_DIRECTORY` | null | path to valid directory on repository. | Build directory. Generally root directory or directory like frontend. |
| `NODE_BUILD_COMMAND` | null | `npm run build` or similar command. | Command used to to build the dependencies needed on deployment. |
| `NODE_BUILD_SCRIPT` | null | path to valid shell script | Custom or predefined script to run after compilation. |
| `BLOCK_EMAILS` | null | true | If set to true, this will enable email blocking functionality. |
| 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. |
| `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. **Note:** Please use double quotes while giving value to this variable. Also, `WP_VERSION`, if defined in hosts.yml will have higher priority then the one defined in workflow file. |
| `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) |
| `SKIP_WP_TASKS` | null | `true`/`false` | If set to `true`, WordPress specific deplyment tasks will skipped. |
| `PHP_VERSION` | 7.4 | Valid PHP version | Determines the cachetool version compatible to use for purging opcache. |
| `NPM_VERSION` | null | Valid NPM Version | NPM Version. If not specified, latest version will be used. |
| `NODE_VERSION` | null | Valid Node Version | If not specified, default version built into action will be used. |
| `NODE_BUILD_DIRECTORY` | null | path to valid directory on repository. | Build directory. Generally root directory or directory like frontend. |
| `NODE_BUILD_COMMAND` | null | `npm run build` or similar command. | Command used to to build the dependencies needed on deployment. |
| `NODE_BUILD_SCRIPT` | null | path to valid shell script | Custom or predefined script to run after compilation. |

All node related variables are completely optional. You can use them if your site needs to have node dependencies built.

Expand Down
6 changes: 3 additions & 3 deletions main.sh
Original file line number Diff line number Diff line change
Expand Up @@ -271,13 +271,13 @@ function block_emails() {
hosts_block_email=$(shyaml get-value "$GITHUB_BRANCH.block_emails" < "$hosts_file" 2>/dev/null || exit 0)

if [[ -n "$hosts_block_email" ]]; then
BLOCK_EMAILS="$hosts_block_email"
match_hosts_block_email=$(echo "$hosts_block_email" | awk '{$1=$1;print tolower($0)}')
fi

if [[ -n "$BLOCK_EMAILS" ]]; then
if [[ "$match_hosts_block_email" == 'true' ]]; then

# priority: 1. hosts.yml 2. vip 3. WP
echo -e "\033[34mSETUP EMAIL BLOCKING\033[0m"
echo -e "\033[34mSETTING UP EMAIL BLOCKING\033[0m"

hosts_block_email_dir=$(shyaml get-value "$GITHUB_BRANCH.block_emails_plugin_path" < "$hosts_file" 2>/dev/null || exit 0)

Expand Down