You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+68-34Lines changed: 68 additions & 34 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,14 +1,20 @@
1
-
This action is a part of [GitHub Actions Library](https://github.com/rtCamp/github-actions-library/) created by [rtCamp](https://github.com/rtCamp/).
1
+
This action is a part of [GitHub Actions Library](https://github.com/rtCamp/github-actions-library/) created
2
+
by [rtCamp](https://github.com/rtCamp/).
2
3
3
4
# Deploy WordPress - GitHub Action
4
5
5
6
[](https://www.repostatus.org/#active)
6
7
7
-
A [GitHub Action](https://github.com/features/actions) to deploy WordPress on a server using [PHP's Deployer.org project](https://deployer.org/).
8
+
A [GitHub Action](https://github.com/features/actions) to deploy WordPress on a server
9
+
using [PHP's Deployer.org project](https://deployer.org/).
8
10
9
-
Please note that, this action expects git repo structure in a certain way. Your webroot should include content inside `wp-content` except `uploads`. You may use our [WordPress Skeleton](https://github.com/rtCamp/wordpress-skeleton) as a base, or restructre existing project to fit in.
11
+
Please note that, this action expects git repo structure in a certain way. Your webroot should include content
12
+
inside `wp-content` except `uploads`. You may use our [WordPress Skeleton](https://github.com/rtCamp/wordpress-skeleton)
13
+
as a base, or restructre existing project to fit in.
10
14
11
-
During deployment, by default this action will download [WordPress](https://wordpress.org/latest.zip), put the content of the repo in `wp-content` directory and then deploy the entire WordPress setup on the deploy path specified in `hosts.yml`.
15
+
During deployment, by default this action will download [WordPress](https://wordpress.org/latest.zip), put the content
16
+
of the repo in `wp-content` directory and then deploy the entire WordPress setup on the deploy path specified
17
+
in `hosts.yml`.
12
18
13
19
`hosts.yml` is [Deployer's inventory file](https://deployer.org/docs/hosts.html#inventory-file).
14
20
@@ -25,29 +31,41 @@ jobs:
25
31
name: Deploy
26
32
runs-on: ubuntu-latest
27
33
steps:
28
-
- uses: actions/checkout@v2
29
-
- name: Deploy
30
-
uses: rtCamp/action-deploy-wordpress@v2
31
-
env:
32
-
SSH_PRIVATE_KEY: ${{ secrets.SSH_PRIVATE_KEY }}
34
+
- uses: actions/checkout@v2
35
+
- name: Deploy
36
+
uses: rtCamp/action-deploy-wordpress@v2
37
+
env:
38
+
SSH_PRIVATE_KEY: ${{ secrets.SSH_PRIVATE_KEY }}
33
39
```
34
40
35
-
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/main/.github/hosts.yml).
37
-
41
+
3. Create `SSH_PRIVATE_KEY` secret
42
+
using [GitHub Action's Secret](https://developer.github.com/actions/creating-workflows/storing-secrets) and store the
43
+
private key that you use use to ssh to server(s) defined in `hosts.yml`.
44
+
4. Create `.github/hosts.yml` inventory file, based
45
+
on [Deployer inventory file](https://deployer.org/docs/hosts.html#inventory-file) format. Make sure you explictly
46
+
define GitHub branch mapping. Only the GitHub branches mapped in `hosts.yml` will be deployed, rest will be filtered
47
+
out. Here is a sample [hosts.yml](https://github.com/rtCamp/wordpress-skeleton/blob/main/.github/hosts.yml).
38
48
39
49
## Environment Variables
40
50
41
51
This GitHub action's behavior can be customized using following environment variables:
`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. WP_VERSION defined in hosts.yml will have higher priority than one defined in workflow file.
47
-
`WP_MINOR_UPDATE`| null | `true` / `false` | If set to `true`, latest minor version of `WP_VERSION` will be taken.
48
-
`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.)
49
-
`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)
`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.
56
+
`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.
57
+
`WP_MINOR_UPDATE`| null | `true` / `false` | If set to `true`, latest minor version of `WP_VERSION` will be taken.
58
+
`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.)
59
+
`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)
60
+
`SKIP_WP_TASKS`| null | `true`/`false` | If set to `true`, WordPress specific deplyment tasks will skipped.
61
+
`PHP_VERSION`| 7.4 | Valid PHP version | Determines the cachetool version compatible to use for purging opcache.
62
+
`NPM_VERSION`| null | Valid NPM Version | NPM Version. If not specified, latest version will be used.
63
+
`NODE_VERSION`| null | Valid Node Version | If not specified, default version built into action will be used.
64
+
`NODE_BUILD_DIRECTORY`| null | path to valid directory on repository. | Build directory. Generally root directory or directory like frontend.
65
+
`NODE_BUILD_COMMAND`| null | `npm run build` or similar command. | Command used to to build the dependencies needed on deployment.
66
+
`NODE_BUILD_SCRIPT`| null | path to valid shell script | Custom or predefined script to run after compilation.
67
+
68
+
All node related variables are completely optional. You can use them if your site needs to have node dependencies built.
51
69
52
70
## Server Setup
53
71
@@ -63,6 +81,7 @@ The Deployer.org expects server setup in a particular way.
63
81
The `current` folder will be automatically created by Deployer during execution.
64
82
65
83
#### Existing Site
84
+
66
85
1. Open file `/opt/easyengine/sites/example.com/config/nginx/conf.d/main.conf`.
67
86
2. Replace `/var/www/htdocs` with `/var/www/htdocs/current`.
1. Make sure your web server points to `current` subdirectory inside original webroot. Make sure `current` subdirectory do NOT exist actually.
96
+
1. Make sure your web server points to `current` subdirectory inside original webroot. Make sure `current` subdirectory
97
+
do NOT exist actually.
78
98
2. You may need to reload your webserver.
79
99
3. You may need to change location of `wp-config.php` as we need in above section.
80
100
81
-
82
101
## Hashicorp Vault (Optional)
83
102
84
-
This GitHub action supports [Hashicorp Vault](https://www.vaultproject.io/). This comes in handy if you manage multiple servers and providing `SSH_PRIVATE_KEY` as GitHub secret per project becomes cumbersome.
103
+
This GitHub action supports [Hashicorp Vault](https://www.vaultproject.io/). This comes in handy if you manage multiple
104
+
servers and providing `SSH_PRIVATE_KEY` as GitHub secret per project becomes cumbersome.
85
105
86
106
To enable Hashicorp Vault support, please define following GitHub secrets:
87
107
@@ -100,17 +120,20 @@ jobs:
100
120
name: Deploy
101
121
runs-on: ubuntu-latest
102
122
steps:
103
-
- uses: actions/checkout@v2
104
-
- name: Deploy
105
-
uses: rtCamp/action-deploy-wordpress@v2
106
-
env:
107
-
VAULT_ADDR: ${{ secrets.VAULT_ADDR }}
108
-
VAULT_TOKEN: ${{ secrets.VAULT_TOKEN }}
123
+
- uses: actions/checkout@v2
124
+
- name: Deploy
125
+
uses: rtCamp/action-deploy-wordpress@v2
126
+
env:
127
+
VAULT_ADDR: ${{ secrets.VAULT_ADDR }}
128
+
VAULT_TOKEN: ${{ secrets.VAULT_TOKEN }}
109
129
```
110
130
111
-
GitHub action uses `VAULT_TOKEN` to connect to `VAULT_ADDR` to retrieve [Signed SSH Certificates](https://www.vaultproject.io/docs/secrets/ssh/signed-ssh-certificates.html#signing-key-amp-role-configuration) and uses it for deployment.
131
+
GitHub action uses `VAULT_TOKEN` to connect to `VAULT_ADDR` to
Please remember that you must configure each of your target deployment server to accept ssh connection via signed certificate using Vault beforehand. Ususally, you need to run following commands once per server:
135
+
Please remember that you must configure each of your target deployment server to accept ssh connection via signed
136
+
certificate using Vault beforehand. Ususally, you need to run following commands once per server:
114
137
115
138
```bash
116
139
export VAULT_ADDR='https://example.com:8200'
@@ -128,9 +151,20 @@ systemctl restart ssh
128
151
129
152
## Overriding default deployement behavior
130
153
131
-
Create a file at location `.github/deploy/deploy.php` in your git repo to provide your own [Deployer.org](https://deployer.org/) script.
132
-
133
-
Please note that it will completely override this action's [original deploy.php](https://github.com/rtCamp/action-deploy-wordpress/blob/master/deploy.php). So if you need some portion of [original deploy.php](https://github.com/rtCamp/action-deploy-wordpress/blob/master/deploy.php), you need to copy that to your own `.github/deploy/deploy.php`.
154
+
1. If you would like to completely override this actions deployer recipe. Create a file at
155
+
location `.github/deploy/deploy.php` in your git repository to provide your own [Deployer.org](https://deployer.org/)
156
+
script.
157
+
* Please note that it will completely override this
158
+
action's [original deploy.php](https://github.com/rtCamp/action-deploy-wordpress/blob/master/deploy.php). So if
159
+
you need some portion
160
+
of [original deploy.php](https://github.com/rtCamp/action-deploy-wordpress/blob/master/deploy.php), you need to
161
+
copy that to your own `.github/deploy/deploy.php`.
162
+
2. If you need to add one or a few custom tasks on top of this actions `deploy.php`, you can create a file at
163
+
location `.github/deploy/addon.php` in your git repository. Checkout the [example addon.php](./example/addon.php) to
164
+
see how to customize it.
165
+
3. If you need to modify the `main.sh` shell script of this action, you can create a file at
166
+
location `.github/deploy/addon.sh` in your git repository. Checkout the [example addon.sh](./example/addon.sh) to see
0 commit comments