• Stars
    star
    120
  • Rank 295,983 (Top 6 %)
  • Language
    Shell
  • License
    MIT License
  • Created over 5 years ago
  • Updated 4 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

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

This action is a part of GitHub Actions Library created by rtCamp.

Deploy WordPress - GitHub Action

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

A GitHub Action to deploy WordPress on a server using PHP's Deployer.org project.

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 as a base, or restructre existing project to fit in.

During deployment, by default this action will download WordPress, 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.

hosts.yml is Deployer'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 the deploy.yml file.
on: push
name: Deploying WordPress Site
jobs:
  deploy:
    name: Deploy
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3
      - name: Deploy
        uses: rtCamp/action-deploy-wordpress@v3
        env:
          SSH_PRIVATE_KEY: ${{ secrets.SSH_PRIVATE_KEY }}
  1. Create SSH_PRIVATE_KEY secret using GitHub Action's Secret and store the private key that you use use to ssh to server(s) defined in hosts.yml.
  2. Create .github/hosts.yml inventory file, based on Deployer 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.

Inventory file Variables

Mandatory

Variable Default Possible Values Purpose
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/ip. eg: example.com hostname for ssh.

Optional

Variable Default Possible Values Description
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.

Environment Variables

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 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.

Server Setup

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

Using EasyEngine v4

New Site

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

The current 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. Run ee site reload example.com.
  4. Move wp-config.php to htdocs. 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 to current subdirectory inside original webroot. Make sure current subdirectory do NOT exist actually.
  2. You may need to reload your webserver.
  3. You may need to change location of wp-config.php as we need in above section.

Hashicorp Vault (Optional)

This GitHub action supports Hashicorp Vault. This comes in handy if you manage multiple servers and providing SSH_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 change secrets line in deploy.yml file to look like below.

on: push
name: Deploying WordPress Site using vault
jobs:
  deploy:
    name: Deploy
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
      - name: Deploy
        uses: rtCamp/action-deploy-wordpress@v3
        env:
          VAULT_ADDR: ${{ secrets.VAULT_ADDR }}
          VAULT_TOKEN: ${{ secrets.VAULT_TOKEN }}

GitHub action uses VAULT_TOKEN to connect to VAULT_ADDR to retrieve Signed 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

Overriding default deployement behavior

  1. If you would like to completely override this actions deployer recipe. Create a file at location .github/deploy/deploy.php in your git repository to provide your own Deployer.org script.
    • Please note that it will completely override this action's original deploy.php. So if you need some portion of original deploy.php, you need to copy that to your own .github/deploy/deploy.php.
  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 location .github/deploy/addon.php in your git repository. Checkout the example addon.php to see how to customize it.
  3. If you need to modify the main.sh shell script of this action, you can create a file at location .github/deploy/addon.sh in your git repository. Checkout the example addon.sh to see how to customize.

License

MIT © 2022 rtCamp

Does this interest you?

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

More Repositories

1

action-slack-notify

GitHub Action for sending a notification to a Slack channel
Go
1,071
star
2

wp-decoupled

Next.js app with WPGraphQL and WordPress at the backend.
JavaScript
267
star
3

nginx-helper

Nginx Helper for WordPress caching, permalinks & efficient file handling in multisite
PHP
229
star
4

VueTheme

WordPress theme using Rest API and Vue.js
CSS
220
star
5

gutenberg-fields-middleware

Register fields for Gutenberg blocks with less repetitive code
JavaScript
167
star
6

rtMedia

rtMedia (formerly Buddypress Media) adds advanced multimedia functionality to WordPress, BuddyPress and bbPress
PHP
121
star
7

Frappe-Manager

A CLI tool based on Docker Compose to easily manage Frappe based projects.
Python
111
star
8

action-phpcs-code-review

Github Action to perform automated code review on pull requests
Shell
101
star
9

github-actions-library

Collection of Github Actions useful for WordPress Deployments
93
star
10

wp-partytown

Add partytown support to WordPress sites.
JavaScript
75
star
11

login-with-google

Minimal plugin which allows WordPress user to login with google.
PHP
62
star
12

learn

rtCamp assignment and issue tracker
51
star
13

rtpanel

WordPress Theme Framework
PHP
43
star
14

gitbook-plugin-edit-link

GitBook Plugin to add "Edit with Github (or Gitlab)" link on every page
JavaScript
42
star
15

wordpress-skeleton

A base repository structure for rtCamp's WordPress sites, pre-configured to use Github Actions
PHP
41
star
16

gutenberg-supplements

JavaScript
28
star
17

rtsocial

rtSocial is lightest wordpress plugin for facebook & twitter social sharing
PHP
26
star
18

theme-elementary

A starter theme that facilitates a quick headstart for developing new block-based themes along with a bunch of developer-friendly features.
JavaScript
26
star
19

wpveda-book

We now have our own training module which has all the lessons that covers the core topics on WordPress and the various steps involved in WordPress development. Check it out
Shell
25
star
20

blank-theme

Customized Blank theme based on Underscore and Foundation
PHP
25
star
21

gitbook-plugin-collapsible-menu

GitBook Plugin to change sidebar menu's to collapsible menu. For gitbook with many pages, navigating long menus can get irritating.
JavaScript
24
star
22

woocommerce-to-easydigitaldownloads

A script to migrate products, orders, payments and other stuff from WooCommerce to EasyDigitalDownloads
PHP
21
star
23

rt-optimizer

A WordPress plugin that improves Core Web Vitals score by loading scripts via worker thread. Keeps the main thread idle for users to interact with page as quickly as possible.
PHP
19
star
24

rtpanel-child-theme

Example child theme for rtPanel wordpress theme framework
CSS
16
star
25

rtbiz

WordPress 4 Business!
PHP
16
star
26

web-story-creation-tool

Demo https://rtcamp.github.io/web-story-creation-tool
JavaScript
16
star
27

wp-menu-custom-fields

An example of custom fields for menu in WordPress 5.4+
TypeScript
16
star
28

woobench-woocommerce-load-testing

WooCommerce Benchmarking
Python
14
star
29

gitlab-to-github-migration

Migrate GitLab project to GitHub
PHP
12
star
30

rt-lib

rt-lib is (intended to be) collection of reusable PHP classes useful for WordPress plugin/theme projects
PHP
12
star
31

transcoder

This WordPress plugin, useful to transcode audio and video file from any format to mp3 and mp4 respectively. Also it will generate thumbnails of videos.
PHP
10
star
32

action-phpcs-inspection

GitHub Action for PHPCS inspection.
Dockerfile
10
star
33

rt-newrelic-browser

NewRelic Browser Monitoring (Real User Monitoring) WordPress
PHP
10
star
34

wordpress-preview-revisions

WordPress Preview Revisions Plugin help editors to preview the revisions with exact same content that would look like on the frontend.
PHP
9
star
35

wp-plugin-bootstrap

A skeleton wordpress plugin to bootstrap & standardize your development
Shell
9
star
36

rtsyntax

A lightweight syntax highlighter for WordPress
CSS
9
star
37

visual-automation-backstop

Visual automation with Backstop JS
JavaScript
9
star
38

media-node

A node.js wrapper for ffmpeg. Made for https://github.com/rtCamp/buddypress-media but can be used in any project which needs FFMPEG
Shell
9
star
39

docs.rtcamp.com

Documentation for rtCamp projects/products
CSS
8
star
40

gutenberg-plugin-boilerplate

Simple Gutenberg Boilerplate for plugin development
JavaScript
8
star
41

search-with-google

A plugin for replacing WordPress default search with Google Custom Search results.
TypeScript
8
star
42

ninja-to-gravity

PHP
7
star
43

pwa-wordpress-plugin

WordPress Plugin to enable PWA features.
PHP
7
star
44

httperf

httperf clone with fix for FD_SETSIZE (open file limit)
C
7
star
45

amp-admanager

Easy and hassle free Google Admanager amp-ad tags integration for all WordPress sites. (AMP and Non-AMP)
PHP
5
star
46

rtpanel-hooks-editor

rtPanel hooks editor plugin provides user-interface for rtPanel WordPress Theme Framework
PHP
5
star
47

my-comment-manager

Better comment management for wordpress
PHP
5
star
48

action-wordpress-org-plugin-deploy

Shell
4
star
49

web-stories-ad-tool

Ad creation tool for google web stories. https://rtcamp.github.io/web-stories-ad-tool
JavaScript
4
star
50

automate-slack-invite-gravityforms

GravityForms addon to invite a user on Slack automatically
PHP
4
star
51

blogger-to-wordpress

Blogger to WordPress Redirection Plugin
TypeScript
4
star
52

rtmedia-code-snippets

This is custom code library for rtMedia core and premium add-ons
PHP
4
star
53

gitlab-bulk-delete-users

Delete users in bulk from Gitlab setup using rake tasks
Ruby
4
star
54

wporg-api-client

WordPress.org API client built in node.js
JavaScript
3
star
55

dockerfiles

Various Dockerfiles in use by rtCamp.
Dockerfile
3
star
56

amp-onesignal-compat

A WordPress Plugin to add AMP compatibility to OneSignal – Web Push Notifications
PHP
3
star
57

pwa-extension

Enables PWA features such as add to homescreen, offline reading features.
PHP
3
star
58

api_playwright_utils

API Automation Testing with Playwright
JavaScript
3
star
59

frappe-dev-tools

App for frappe devs to go 🚀
Python
3
star
60

integrate-woocommerce-gitlab

With this code users can connect GitLab to WooCommerce, users will get source code repositories access as a Guest, Reporter, Developer or Master
PHP
3
star
61

wp-cli-report-command

Lists the plugin and theme usage for a multisite
PHP
2
star
62

wercker-step-wordpress-svn

Wercker deploy step for wordpress.org plugin svn repo
Shell
2
star
63

rtbiz-helpdesk

PHP
2
star
64

migrate-wufoo-to-gravity-forms

Import content from wufoo to Gravity Form- Entries, Comments and attachments.
PHP
2
star
65

blocks-bento-variations

PHP
2
star
66

px-wp-insights

AMP Compatibility Database
JavaScript
2
star
67

amp-generic-compat

AMP plugin to provide generic compatibility for Elements with hide and show toggle feature
PHP
2
star
68

rtWidgets

Sidebar Widgets Collection for rtPanel Theme Framework mainly. Might work on other theme as well.
PHP
2
star
69

embed-google-drive

TypeScript
2
star
70

rtmoto

rtMoto Theme
PHP
2
star
71

mention-links

Plugin which brings Github style user @mentions and article #links to the WordPress
TypeScript
2
star
72

stripe-xero-csv

Export Stripe's balance affecting transactions in a CSV file, recognisable by Xero Import CSV Statement feature.
PHP
2
star
73

action-deploy-frappe

Shell
2
star
74

edit-flow-slack-integration

This plugin is to send slack notification when editotial comment added.
PHP
1
star
75

lando-wordpress-skeleton

PHP
1
star
76

action-deploy-on-managed-instance

Shell
1
star
77

amp-infinite-scroll

AMP plugin for infinite scroll
PHP
1
star
78

web-stories-playground

JavaScript
1
star
79

rtAdmin

PHP-CLI nginx vhost creation script. Succeeded by https://github.com/rtCamp/easyengine
PHP
1
star
80

rtAntiSpam

WordPress login/register sidebar widget with recaptcha support
PHP
1
star
81

wp-cls-terminator

Remove CLS from Block Editor Embeds
JavaScript
1
star
82

rt-google-analytics-scroll-tracking

Integrates jquery-scrolldepth with Google Analytics by Yoast
JavaScript
1
star
83

amp-colormag-compat

Adds Compatibility to WordPress ColorMag theme.
PHP
1
star
84

gitolite-setup

Setup scripts for Gitolite v3
Shell
1
star
85

AMP-Extensions-Mini-Plugins

Monorepo contains different AMP extension plugins
PHP
1
star
86

psat-demos

EJS
1
star
87

rtmedia-transcoding-service-old

rtmedia Transcoding Plugin for rtMedia and WordPress Media Library
PHP
1
star
88

rt-react-theme

JavaScript
1
star
89

gravityforms-sfmc-data-extension

Gravity Forms add-on to send entry data to a Salesforce Marketing Cloud Data Extension
PHP
1
star
90

amp-email-subscribers

AMP compatibility for Email Subscribers & Newsletters – Simple and Effective Email Marketing WordPress Plugin by icegram
PHP
1
star