Solving the Workflow - Building MODX.today with Gitify (2015-05-21, Alkmaar)

49
Solving the Workflow or how MODX.today is being managed across 3 servers with Git & Gitify

Transcript of Solving the Workflow - Building MODX.today with Gitify (2015-05-21, Alkmaar)

Page 1: Solving the Workflow - Building MODX.today with Gitify (2015-05-21, Alkmaar)

Solving the Workflowor how MODX.today is being managed

across 3 servers with Git & Gitify

Page 2: Solving the Workflow - Building MODX.today with Gitify (2015-05-21, Alkmaar)

Who am I?!Mark Hamstra

Founder & CEA at modmore Freelance MODX Developer

Not me

Turbo

Bommel

Page 3: Solving the Workflow - Building MODX.today with Gitify (2015-05-21, Alkmaar)

Solving the Workflow

Introducing the project: MODX.today

Introducing the tools: Gitify & Git

Putting it together: designing a Workflow

Setting up automatic deployments

Page 4: Solving the Workflow - Building MODX.today with Gitify (2015-05-21, Alkmaar)

What is MODX.today?

Page 5: Solving the Workflow - Building MODX.today with Gitify (2015-05-21, Alkmaar)

MODX.today

• Daily-ish posts about MODX

• Weekly newsletter / reading list

• Open source, looking for guest authors

• Launched April 22nd

• 5500+ pageviews, average time on site 2:25 min

Page 6: Solving the Workflow - Building MODX.today with Gitify (2015-05-21, Alkmaar)
Page 7: Solving the Workflow - Building MODX.today with Gitify (2015-05-21, Alkmaar)
Page 8: Solving the Workflow - Building MODX.today with Gitify (2015-05-21, Alkmaar)
Page 9: Solving the Workflow - Building MODX.today with Gitify (2015-05-21, Alkmaar)
Page 10: Solving the Workflow - Building MODX.today with Gitify (2015-05-21, Alkmaar)
Page 11: Solving the Workflow - Building MODX.today with Gitify (2015-05-21, Alkmaar)
Page 12: Solving the Workflow - Building MODX.today with Gitify (2015-05-21, Alkmaar)
Page 13: Solving the Workflow - Building MODX.today with Gitify (2015-05-21, Alkmaar)
Page 14: Solving the Workflow - Building MODX.today with Gitify (2015-05-21, Alkmaar)

github.com/modmore/MODX.today

Page 15: Solving the Workflow - Building MODX.today with Gitify (2015-05-21, Alkmaar)

Solving the Workflow

Introducing the project: MODX.today

Introducing the tools: Gitify & Git

Putting it together: designing a Workflow

Setting up automatic deployments

Page 16: Solving the Workflow - Building MODX.today with Gitify (2015-05-21, Alkmaar)

What is Gitify?

Page 17: Solving the Workflow - Building MODX.today with Gitify (2015-05-21, Alkmaar)

Gitify is not…

• A complete, all-in-one, drag-and-drop solution with a fancy user interface with buttons and animations

• The only way to have a workflow in MODX

Page 18: Solving the Workflow - Building MODX.today with Gitify (2015-05-21, Alkmaar)

But, Gitify is…

• A useful addition to your toolkit

• Flexible to mix & match with other tools

• Built on top of Symfony2 Console

• Open source!

Page 19: Solving the Workflow - Building MODX.today with Gitify (2015-05-21, Alkmaar)

With Gitify, you can…

• easily create file representations of any object

• create a functional site from those files

• install MODX and packages

• create mysql backups (and restore them)

Page 20: Solving the Workflow - Building MODX.today with Gitify (2015-05-21, Alkmaar)

Installing Gitify

• Go to https://github.com/modmore/Gitify and follow the instructions. Basically:

• $ git clone https://github.com/modmore/Gitify.git Gitify

• $ cd Gitify

• $ composer install (or php composer.phar install)

• $ chmod +x Gitify

• Add Gitify to your $PATH - check the wiki

Page 21: Solving the Workflow - Building MODX.today with Gitify (2015-05-21, Alkmaar)

Running Gitify

Page 22: Solving the Workflow - Building MODX.today with Gitify (2015-05-21, Alkmaar)

$ Gitify init• Sets up a new Gitify configuration

file interactively.

• --overwrite flag allows you to create a new config file if one already exists.

Page 23: Solving the Workflow - Building MODX.today with Gitify (2015-05-21, Alkmaar)

.gitify filedata_directory: _data/ backup_directory: _backup/ data: contexts: class: modContext primary: key content: type: content exclude_keys: - editedby - editedon categories: class: modCategory primary: category templates: class: modTemplate primary: templatename template_variables: class: modTemplateVar primary: name

packages: modx.com: service_url: http://rest.modx.com/extras/ packages: - ace - breadcrumbs - collections - getresources - getcache - seopro - translit - templateselect - wayfinder

Page 24: Solving the Workflow - Building MODX.today with Gitify (2015-05-21, Alkmaar)

$ Gitify extract

• Looks at your .gitify configuration to extract data from MODX, which is written to files in your data directory.

• Allows specifying any number of partitions (directories/types) you want extracted

Page 25: Solving the Workflow - Building MODX.today with Gitify (2015-05-21, Alkmaar)

Gitify Extract (#2)id: 4 templatename: 'Empty Content' description: 'Default Template with empty Content Area' properties: 'a:0:{}'

-----

[[$template.head]] [[$template.header]] <!-- #content --> <div id="content" role="main"> [[*content]] </div> <!-- / #content --> [[$template.footer]]

Page 26: Solving the Workflow - Building MODX.today with Gitify (2015-05-21, Alkmaar)

• Reads the gitify directory, and builds it into the MODX install

• —force flag clears all data first

• —skip-clear-cache flag allows building without clearing cache

• —no-backup allows skipping creating a backup with —force

• —no-cleanup allows skipping cleaning up orphaned objects

$ Gitify build

Page 27: Solving the Workflow - Building MODX.today with Gitify (2015-05-21, Alkmaar)
Page 28: Solving the Workflow - Building MODX.today with Gitify (2015-05-21, Alkmaar)

Build Magic

• Automatically resolves ID conflicts by analysing existing and already built objects

• Cleans up orphaned objects from the database

• Still respects where conditions in .gitify

Page 29: Solving the Workflow - Building MODX.today with Gitify (2015-05-21, Alkmaar)

$ Gitify modx:install

• Downloads and installs a version of MODX all from the command line.

• [modx_version] argument lets you define a version (e.g. 2.3.2-pl) that will be installed. Without it, the latest version will be grabbed.

Page 30: Solving the Workflow - Building MODX.today with Gitify (2015-05-21, Alkmaar)

$ Gitify package:install

• Downloads and installs a package (extra) into the MODX installation.

• —all option will look at the .gitify file and automatically install each of the packages defined there.

• —interactive option allows to interactively search and install packages when used with —all.

• [package_name] argument accepts a partial name of the package which it will then try to find in the package provider.

Page 31: Solving the Workflow - Building MODX.today with Gitify (2015-05-21, Alkmaar)

$ Gitify backup

• Creates a backup of your MySQL database using mysqldump

• [name] the filename for the backup file

Page 32: Solving the Workflow - Building MODX.today with Gitify (2015-05-21, Alkmaar)

$ Gitify restore

• Restores a backup created with Gitify backup.

• [file] If you know the filename, you can pass it directly. Otherwise you will get an interactive list of the available backups that can be restored.

Page 33: Solving the Workflow - Building MODX.today with Gitify (2015-05-21, Alkmaar)

Solving the Workflow

Introducing the project: MODX.today

Introducing the tools: Gitify & Git

Putting it together: designing a Workflow

Setting up automatic deployments

Page 34: Solving the Workflow - Building MODX.today with Gitify (2015-05-21, Alkmaar)

The WorkflowGit Repository

Page 35: Solving the Workflow - Building MODX.today with Gitify (2015-05-21, Alkmaar)

The WorkflowGit Repository

develop production

staging

Page 36: Solving the Workflow - Building MODX.today with Gitify (2015-05-21, Alkmaar)

The Workflow

site.com

Git Repository

site.dev

staging.site.com

develop production

staginggit push

git pull

git p

ush

git p

ull

git pull

Page 37: Solving the Workflow - Building MODX.today with Gitify (2015-05-21, Alkmaar)

The Workflow

site.com

Git Repository

site.dev

staging.site.com

develop production

staginggit merge git merge

Page 38: Solving the Workflow - Building MODX.today with Gitify (2015-05-21, Alkmaar)

The Workflow

site.com

Git Repository

staging.site.com

develop production

staging

site.dev

Commit Changes to GitSynchronise with Git Repository

Gitify extract

Build stuff in MODX

Gitify build

Page 39: Solving the Workflow - Building MODX.today with Gitify (2015-05-21, Alkmaar)

The Workflow

site.com

Git Repository

staging.site.com

develop production

stagingCommit Changes to Git

Synchronise with Git Repository

(Gitify extract)

Make a Changein Gitify Files

Gitify build

Test changes

site.dev

Page 40: Solving the Workflow - Building MODX.today with Gitify (2015-05-21, Alkmaar)

The Workflow

site.com

Git Repository

site.dev

staging.site.com

develop production

staging

Page 41: Solving the Workflow - Building MODX.today with Gitify (2015-05-21, Alkmaar)

The Workflow

site.com

Git Repository

site.dev

develop production

staging

Gitify WatchSchedules Extract

Make change in MODX

staging.site.com

Gitify extractgit add -a

git commit

git pu

sh

Page 42: Solving the Workflow - Building MODX.today with Gitify (2015-05-21, Alkmaar)

The Workflow

site.com

Git Repository

site.dev

staging.site.com

develop production

staging

Page 43: Solving the Workflow - Building MODX.today with Gitify (2015-05-21, Alkmaar)

The Workflow

site.com

Git Repository

site.dev

staging.site.com

develop production

staging deploy

Page 44: Solving the Workflow - Building MODX.today with Gitify (2015-05-21, Alkmaar)

Solving the Workflow

Introducing the project: MODX.today

Introducing the tools: Gitify & Git

Putting it together: designing a Workflow

Setting up automatic deployments

Page 45: Solving the Workflow - Building MODX.today with Gitify (2015-05-21, Alkmaar)

Setting up a Site from Gitify

1. Clone the Repository, checkout proper branch

2. Install MODX (Gitify modx:install

[version])

3. Install defined packages (Gitify

package:install —all)

4. Build from files (Gitify build)

Page 46: Solving the Workflow - Building MODX.today with Gitify (2015-05-21, Alkmaar)

Updating a Site from Gitify

1. Pull in the latest version of the repository

2. Install defined packages (Gitify install:package —all)

3. Build from files (Gitify build)

Page 47: Solving the Workflow - Building MODX.today with Gitify (2015-05-21, Alkmaar)

Handling Automatic Deploys (#1)

• Use a Github/Gitlab/Bitbucket webhook that requests a PHP script like this:

<?php

`git fetch origin`;

`git reset --hard origin/production`;

`git pull origin production`;

`Gitify install:package —all`;

`Gitify build —force`;

Page 48: Solving the Workflow - Building MODX.today with Gitify (2015-05-21, Alkmaar)

Handling Automatic Deploys (#2)

• Use a CI / Deployment service / tool: dploy.io

Page 49: Solving the Workflow - Building MODX.today with Gitify (2015-05-21, Alkmaar)

The End

Useful links:

• MODX.today• MODX.today/submit• github.com/modmore/Gitify• github.com/modmore/Gitify/wiki/Home• github.com/modmore/MODX.today