- Notifications
You must be signed in to change notification settings - Fork32
GitHub Action for deploying a WordPress site using using PHP's Deployer.org
License
rtCamp/action-deploy-wordpress
Folders and files
| Name | Name | Last commit message | Last commit date | |
|---|---|---|---|---|
Repository files navigation
This action is a part ofGitHub Actions Library created byrtCamp.
AGitHub Action to deploy WordPress on a server usingPHP's Deployer.org project.
Please note that, this action expects git repo structure in a certain way. Your webroot should include content insidewp-content exceptuploads. You may use ourWordPress Skeleton as a base, or restructre existing project to fit in.
During deployment, by default this action will downloadWordPress, put the content of the repo inwp-content directory and then deploy the entire WordPress setup on the deploy path specified inhosts.yml.
hosts.yml isDeployer's inventory file.
- Create a
.github/workflows/deploy.ymlfile in your GitHub repo, if one doesn't exist already. - Add the following code to the
deploy.ymlfile.
on:pushname:Deploying WordPress Sitejobs:deploy:name:Deployruns-on:ubuntu-lateststeps: -uses:actions/checkout@v2 -name:Deployuses:rtCamp/action-deploy-wordpress@v2env:SSH_PRIVATE_KEY:${{ secrets.SSH_PRIVATE_KEY }}
- Create
SSH_PRIVATE_KEYsecret usingGitHub Action's Secret and store the private key that you use use to ssh to server(s) defined inhosts.yml. - Create
.github/hosts.ymlinventory file, based onDeployer inventory file format. Make sure you explictly define GitHub branch mapping. Only the GitHub branches mapped inhosts.ymlwill be deployed, rest will be filtered out. Here is a samplehosts.yml.
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 isvip, then action will cloneVIP's MU plugins asmu-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_VERSION defined in hosts.yml will have higher priority than one defined in workflow file. |
WP_MINOR_UPDATE | null | true /false | If set totrue, latest minor version ofWP_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: TheSSH_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) |
The Deployer.org expects server setup in a particular way.
UsingEasyEngine v4
- Pass flag
--public-dir=currentduring site creation. - Delete the
currentfolder usingrm -r /opt/easyengine/sites/example.com/app/htdocs/current.
Thecurrent folder will be automatically created by Deployer during execution.
- Open file
/opt/easyengine/sites/example.com/config/nginx/conf.d/main.conf. - Replace
/var/www/htdocswith/var/www/htdocs/current. - Run
ee site reload example.com. - Move
wp-config.phptohtdocs. You can use following command:
mv /opt/easyengine/sites/example.com/app/wp-config.php /opt/easyengine/sites/example.com/app/htdocs/wp-config.php
- Make sure your web server points to
currentsubdirectory inside original webroot. Make surecurrentsubdirectory do NOT exist actually. - You may need to reload your webserver.
- You may need to change location of
wp-config.phpas we need in above section.
This GitHub action supportsHashicorp Vault. This comes in handy if you manage multiple servers and providingSSH_PRIVATE_KEY as GitHub secret per project becomes cumbersome.
To enable Hashicorp Vault support, please define following GitHub secrets:
| Variable | Purpose | Example Vaule |
|---|---|---|
VAULT_ADDR | Vault server address | https://example.com:8200 |
VAULT_TOKEN | Vault token | s.gIX5MKov9TUp7iiIqhrP1HgN |
You will need to changesecrets line indeploy.yml file to look like below.
on:pushname:Deploying WordPress Site using vaultjobs:deploy:name:Deployruns-on:ubuntu-lateststeps: -uses:actions/checkout@v2 -name:Deployuses:rtCamp/action-deploy-wordpress@v2env:VAULT_ADDR:${{ secrets.VAULT_ADDR }}VAULT_TOKEN:${{ secrets.VAULT_TOKEN }}
GitHub action usesVAULT_TOKEN to connect toVAULT_ADDR to retrieveSigned SSH Certificates and uses it for deployment.
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:
export VAULT_ADDR='https://example.com:8200'export VAULT_TOKEN='s.gIX5MKov9TUp7iiIqhrP1HgN'# Add the public key to all target host's SSH configuration.curl -o /etc/ssh/trusted-user-ca-keys.pem"$VAULT_ADDR/v1/ssh-client-signer/public_key"# Add the path where the public key contents are stored to the SSH configuration file as the TrustedUserCAKeys option.echo"TrustedUserCAKeys /etc/ssh/trusted-user-ca-keys.pem">> /etc/ssh/sshd_config# Restart ssh service. This may differ according to the OS.systemctl restart ssh
Create a file at location.github/deploy/deploy.php in your git repo to provide your ownDeployer.org script.
Please note that it will completely override this action'soriginal deploy.php. So if you need some portion oforiginal deploy.php, you need to copy that to your own.github/deploy/deploy.php.
MIT © 2021 rtCamp
About
GitHub Action for deploying a WordPress site using using PHP's Deployer.org
Topics
Resources
License
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Packages0
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Contributors11
Uh oh!
There was an error while loading.Please reload this page.
