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

Preview:

Citation preview

Solving the Workflowor how MODX.today is being managed

across 3 servers with Git & Gitify

Who am I?!Mark Hamstra

Founder & CEA at modmore Freelance MODX Developer

Not me

Turbo

Bommel

Solving the Workflow

Introducing the project: MODX.today

Introducing the tools: Gitify & Git

Putting it together: designing a Workflow

Setting up automatic deployments

What is MODX.today?

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

github.com/modmore/MODX.today

Solving the Workflow

Introducing the project: MODX.today

Introducing the tools: Gitify & Git

Putting it together: designing a Workflow

Setting up automatic deployments

What is Gitify?

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

But, Gitify is…

• A useful addition to your toolkit

• Flexible to mix & match with other tools

• Built on top of Symfony2 Console

• Open source!

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)

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

Running Gitify

$ Gitify init• Sets up a new Gitify configuration

file interactively.

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

.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

$ 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

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

• 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

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

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

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

$ Gitify backup

• Creates a backup of your MySQL database using mysqldump

• [name] the filename for the backup file

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

Solving the Workflow

Introducing the project: MODX.today

Introducing the tools: Gitify & Git

Putting it together: designing a Workflow

Setting up automatic deployments

The WorkflowGit Repository

The WorkflowGit Repository

develop production

staging

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

The Workflow

site.com

Git Repository

site.dev

staging.site.com

develop production

staginggit merge git merge

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

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

The Workflow

site.com

Git Repository

site.dev

staging.site.com

develop production

staging

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

The Workflow

site.com

Git Repository

site.dev

staging.site.com

develop production

staging

The Workflow

site.com

Git Repository

site.dev

staging.site.com

develop production

staging deploy

Solving the Workflow

Introducing the project: MODX.today

Introducing the tools: Gitify & Git

Putting it together: designing a Workflow

Setting up automatic deployments

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)

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)

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`;

Handling Automatic Deploys (#2)

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

The End

Useful links:

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

Recommended