• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar

Ani's Webdev Blog

A learning diary of website development

  • Home
  • Demo
    • Ajax Contact Form
  • WordPress
  • Front-end
  • Backend

Installing Revisr on Amazon LightSail WordPress Instances That Deployed With GitHub

Modified on: July 4, 2020

This post is an extended article for the early post: WordPress Deployment Workflow: Amazon LightSail, GitHub and Revisr.

Table of contents

  1. Basic Use / Requisites
    1. Server requirements
      1. Revisr Settings
        1. General
          1. Remote
            1. Database
            2. Creating Webhooks on GitHub
              1. Steps
              2. Securing .git folder and .gitignore

                Revisr is a WordPress plugin to fastly deploy GitHub codes to WordPress websites (and it is a free tool). This plugin can be installed from WordPress plugin marketplace.

                Let’s review this situation:

                • We have a staging environment which is on the same dev branch with our local host, for development purpose
                • 3 instances of production websites which run under a load balancer, on the master branch (this branch should have the most stable version of the website)

                Revisr will help:

                • Each time there is a Git Push from localhost to GitHub, code auto deployed to the staging live site, because both localhost and staging site have Revisr watched over the same branch
                • Each time there is a merge from dev branch into master on Github, code auto deployed to all 3 production instances, at the same time.

                So no need to login to the SSH terminal and run git pull on each website instance each time we want to see the changes alive.

                figure: workflow with revisr and github on wordpress sites

                Basic Use / Requisites

                Install Revisr plugin on the website instances that you want to pull content / updates.

                In case you are running several instances under a load balancer, install Revisr on all of them.

                In this post, we will see how to install and run Revisr on HTTPS method.

                Server requirements

                The Revisr needs to be able to write on the .git/config and .git/objects so we have to make some changes to the LightSail instances.

                • For each instance, go to Amazon LightSail > SSH into the system.
                Shell

                To make sure the system works fine:

                • Go to Revisr Settings (from WP Dashboard) > Help. Repository Writable has to be true
                • Revisr > Dashboard. Make a test Pull Changes, it should not inform any errors.

                Revisr Settings

                General

                Fill in Git Username and Email. Others like .gitignore will be from the current repo that Revisr recognizes.

                Remote

                We are using HTTPS method, stating the Git username and password in the Remote URL itself. To make it secure, obtain a PAT from Github so that we can use a token to replace our current password.

                • Remote URL: https://username:{PAT-token}@github.com/{user}/{repo-link}.git
                • Check this option: Automatically pull new commits?. It will generate a payload URL for the Github webhooks which we will implement a bit later.

                Database

                In this case, we don’t need to track database at all because the database is from a cloud storage (RDS / Google Cloud Platform) so each time the local server’s database change it will take effect on the live site also.

                • Database Tables to track: None

                Creating Webhooks on GitHub

                After installing and complete the Revisr settings on WordPress, we create webhooks on Github. Basically we just need to go to the Github repo > Settings > Webhooks > Add webhook and paste in the link that Revisr provides as the Payload URL.

                Each instance’s website URL can be assigned with a static IP on Amazon LightSail so the URLs that Revisr auto pull generate are quite stable (it does not change if the instance is rebooted or restarted).

                Steps

                For each Amazon LightSail instances:

                • Copy the URL from Revisr Settings > Remote > Automatically pull new commits? as the Payload URL. Choose event push. Assume that we have 3 instances of websites running under a load balancer, we will have then 3 webhooks.
                • If you want to trigger the autopull based on a merge, choose push and then set the plugin to watch on master (supposed that you join the new codes into dev branch and then finally merge the perfect version into master).
                Even though the database is shared, this URL will be different for each instance, based on the IP address of the web instance.
                Even though the database is shared, this URL will be different for each instance, based on the IP address of the web instance.
                Webhooks will be created from GitHub

                Securing .git folder and .gitignore

                Make a 404 redirect to all access starting at .git after the domain name by configuring Apache:

                Shell

                Add to the last line:

                Shell

                Restart Apache

                Shell

                Filed Under: Backend, Wordpress, Wordpress Plugins

                Recent posts

                [WordPress] Let’s Make Plugin E01: A Simple View Count Plugin

                [WordPress] Create custom post type programmatically

                [WordPress] Open Images in Posts into Lightboxes On Clicks (Without Plugins)

                Reader Interactions

                You are here: Home / Backend / Installing Revisr on Amazon LightSail WordPress Instances That Deployed With GitHub

                Leave a Reply Cancel reply

                Your email address will not be published. Required fields are marked *

                Primary Sidebar

                Hi! I am a Vietnamese coder living in Oulu, Finland. Currently I am working with PHP, MySQL, HTML, CSS, and JavaScript. This blog is my learning diary, in which I share knowledge from my own experience or research. Hopefully you can find something useful here and don’t hesitate to open a discussion or leave a feedback!

                FOLLOW MY BLOG

                Thank you for visiting this website! I hope you find something useful here :). Contact me by email: anh@anhkarppinen.com.