Hi,
I happened to try Siteground's staging functionality, and I was thinking that it would be very nice if we could have something similar, only with the command-line. Here is how I envision it in my ideal scenario:
First, we could have a command like:
stage example.com -to=staging.example.com
which would:
- Clone example.com to staging.example.com
- Detect their connection somehow and show it as staging when you do a site -list. e.g.:
+ site1.com
+ example.com
- staging.example.com (staging of example.com)
+ site2.com - Enable debug mode on wp-config.php
- Password protect the entire staging site
- Disable caching
- Maybe an additional option to block any email notifications send to non-admins, in order to prevent accidental notifications to users (e.g. to customers of an eshop).
If you ran
stage example.com
without any parameter, it would search if a staging site exists and if it did, it would automatically perform the aforementioned actions to it, practically updating the existing staging site with the latest changes from the live.
Similarly, if you ran
stage example.com -to=example2.com
supposing that both example.com and example2.com already exist as separate webinoly websites, it would practically connect the two sites as live and staging and update the staging with the latest version of the live.
Then, a command like:
deploy staging.example.com -mode=[full | functionality | custom]
which would:
- Create a full local backup of the current version of the live site (files and database). If an earlier backup from a previous deploy already exists, it gets replaced. It's not a versioning solution, so we would only need the backup just in case something goes wrong. In fact, it could even have an expiration date (e.g. automatically deleted after a day, a week, or a month).
- Push the changes to the live site, based on the option set with -mode:
- "full", would overwrite everything, no questions asked.
- "functionality" (it probably needs a better name) would overwrite the plugins and themes folders as well as everything in the database except for the content-related tables like wp_users, wp_posts, wp_comments, woocommerce orders etc. Basically, the goal here is to update the plugins, theme and their settings but leave out anything content-related.
- "custom", where you would be asked to specifically declare which folders and tables you want to exclude (or include).
- Remove password protection (unless the live site already had one for whatever reason, in which case we keep it).
- Enable caching, if the live site had it enabled
- Disable debug mode
- Enable back the normal email functionality
Finally, we would obviously also need a restore command in case something went wrong.
I know that it sounds a bit crazy, that it definitely needs more overall thinking and that it's probably out of the scope of this project, but maybe some parts of it could fit in.