Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

GitHub Action for deploying a WordPress site using using PHP's Deployer.org

License

NotificationsYou must be signed in to change notification settings

rtCamp/action-deploy-wordpress

Use this GitHub action with your project
Add this Action to an existing workflow or create a new one
View on Marketplace

Repository files navigation

This action is a part ofGitHub Actions Library createdbyrtCamp.

Deploy WordPress - GitHub Action

Project Status: Active – The project has reached a stable, usable state and is being actively developed.

AGitHub Action to deploy WordPress on a serverusingPHP's Deployer.org project.

Please note that, this action expects git repo structure in a certain way. Your webroot should include contentinsidewp-content exceptuploads. You may use ourWordPress Skeletonas a base, or restructre existing project to fit in.

During deployment, by default this action will downloadWordPress, put the contentof the repo inwp-content directory and then deploy the entire WordPress setup on the deploy path specifiedinhosts.yml.

hosts.yml isDeployer's inventory file.

Usage

  1. Create a.github/workflows/deploy.yml file in your GitHub repo, if one doesn't exist already.
  2. Add the following code to thedeploy.yml file.
on:pushname:Deploying WordPress Sitejobs:deploy:name:Deployruns-on:ubuntu-lateststeps:      -uses:actions/checkout@v2      -name:Deployuses:rtCamp/action-deploy-wordpress@v3env:SSH_PRIVATE_KEY:${{ secrets.SSH_PRIVATE_KEY }}
  1. CreateSSH_PRIVATE_KEY secretusingGitHub Action's Secret and store theprivate key that you use use to ssh to server(s) defined inhosts.yml.
  2. Create.github/hosts.yml inventory file, basedonDeployer inventory file format. Make sure you explictlydefine GitHub branch mapping. Only the GitHub branches mapped inhosts.yml will be deployed, rest will be filteredout. Here is a samplehosts.yml.

Environment Variables

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

VariableDefaultPossible ValuesPurpose
MU_PLUGINS_URLnullvip, any git repo urlIf 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_VERSIONlatestAny valid WordPress versionIf 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_UPDATEnulltrue /falseIf set totrue, latest minor version ofWP_VERSION will be taken.
JUMPHOST_SERVERnullHostname/IP address of the jumphost serverIf 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_KEYnullRead 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_TASKSnulltrue/falseIf set totrue, WordPress specific deplyment tasks will skipped.
PHP_VERSION7.4Valid PHP versionDetermines the cachetool version compatible to use for purging opcache.
NPM_VERSIONnullValid NPM VersionNPM Version. If not specified, latest version will be used.
NODE_VERSIONnullValid Node VersionIf not specified, default version built into action will be used.
NODE_BUILD_DIRECTORYnullpath to valid directory on repository.Build directory. Generally root directory or directory like frontend.
NODE_BUILD_COMMANDnullnpm run build or similar command.Command used to to build the dependencies needed on deployment.
NODE_BUILD_SCRIPTnullpath to valid shell scriptCustom 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.

Server Setup

The Deployer.org expects server setup in a particular way.

UsingEasyEngine v4

New Site

  1. Pass flag--public-dir=current during site creation.
  2. Delete thecurrent folder usingrm -r /opt/easyengine/sites/example.com/app/htdocs/current.

Thecurrent folder will be automatically created by Deployer during execution.

Existing Site

  1. Open file/opt/easyengine/sites/example.com/config/nginx/conf.d/main.conf.
  2. Replace/var/www/htdocs with/var/www/htdocs/current.
  3. Runee site reload example.com.
  4. Movewp-config.php tohtdocs. 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

Not using EasyEngine

  1. Make sure your web server points tocurrent subdirectory inside original webroot. Make surecurrent subdirectorydo NOT exist actually.
  2. You may need to reload your webserver.
  3. You may need to change location ofwp-config.php as we need in above section.

Hashicorp Vault (Optional)

This GitHub action supportsHashicorp Vault. This comes in handy if you manage multipleservers and providingSSH_PRIVATE_KEY as GitHub secret per project becomes cumbersome.

To enable Hashicorp Vault support, please define following GitHub secrets:

VariablePurposeExample Vaule
VAULT_ADDRVault server addresshttps://example.com:8200
VAULT_TOKENVault tokens.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@v3env:VAULT_ADDR:${{ secrets.VAULT_ADDR }}VAULT_TOKEN:${{ secrets.VAULT_TOKEN }}

GitHub action usesVAULT_TOKEN to connect toVAULT_ADDR toretrieveSigned SSH Certificatesand uses it for deployment.

Please remember that you must configure each of your target deployment server to accept ssh connection via signedcertificate 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

Overriding default deployement behavior

  1. If you would like to completely override this actions deployer recipe. Create a file atlocation.github/deploy/deploy.php in your git repository to provide your ownDeployer.orgscript.
  2. If you need to add one or a few custom tasks on top of this actionsdeploy.php, you can create a file atlocation.github/deploy/addon.php in your git repository. Checkout theexample addon.php tosee how to customize it.
  3. If you need to modify themain.sh shell script of this action, you can create a file atlocation.github/deploy/addon.sh in your git repository. Checkout theexample addon.sh to seehow to customize.

License

MIT © 2022 rtCamp

Does this interest you?

Join us at rtCamp, we specialize in providing high performance enterprise WordPress solutions

About

GitHub Action for deploying a WordPress site using using PHP's Deployer.org

Topics

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors11


[8]ページ先頭

©2009-2025 Movatter.jp