Skip to content

Auto update your website

Foad Yousefi edited this page Feb 28, 2018 · 8 revisions

Generate build.yml

Running wp build-generate will list all active plugins and active theme with their current version in the build.yml file that looks like this:

core:
    download:
        version: 4.9.4
        locale: en_US
plugins:
    advanced-custom-fields:
        version: 4.4.12
    timber-library:
        version: 1.7.0
    wordpress-popular-posts:
        version: 4.0.13
    wordpress-seo:
        version: 6.3.1
themes:
    twentyseventeen:
        version: 1.4

Here you can specify which plugin or theme to auto update or which one that has breaking changes potential, should remain on a fixed version.

You have these choices:

  1. '*' Latest version
  2. '4.9.*' Latest minor version
  3. 1.7.0 Fixed version

Following is a copy of one of our production websites:

core:
    download:
        version: 4.9.4
        locale: nb_NO
plugins:
    adblock-notify-by-bweb:
        version: '*'
    advanced-custom-fields:
        version: '*'
    amp:
        version: '*'
    co-authors-plus:
        version: '*'
    disable-comments:
        version: '*'
    elasticpress:
        version: 2.3.2
    shortcode-ui:
        version: '*'
    timber-library:
        version: 1.7.0
    tinymce-advanced:
        version: '*'
    wordpress-popular-posts:
        version: '*'
    wp-super-cache:
        version: '*'
    wordpress-seo:
        version: '*'

This example don't contain any theme, because we use custom build theme.

Create crom job on the server

On the server create a shell script that runs wp build command. Our instance looks like:

cd /path/to/website/root/directory(public_html)
/usr/local/bin/wp build

Don’t forget to give the shell script correct permission. In this case, 755.

Then create cron job by running crontab -e

And create cron job as your need and how aften you want to run it:

0 1 * * * /path/to/shell/script/update.sh 1&>/dev/null

This example, will run every night at one o'clock.

Clone this wiki locally