dev, staging & production workflow with gitify (at modxpo 2015 in munich)

79
Dev, Staging & Production Workflow with Gitify Mark Hamstra, @mark_hamstra

Upload: mark-hamstra

Post on 12-Apr-2017

1.216 views

Category:

Internet


3 download

TRANSCRIPT

Page 1: Dev, Staging & Production Workflow with Gitify (at MODXpo 2015 in Munich)

Dev, Staging & Production Workflow with Gitify

Mark Hamstra, @mark_hamstra

Page 2: Dev, Staging & Production Workflow with Gitify (at MODXpo 2015 in Munich)

What is a Dev/Stage/Production Workflow?

Page 3: Dev, Staging & Production Workflow with Gitify (at MODXpo 2015 in Munich)

What is a Dev/Stage/Production Workflow?

• One site or project

Page 4: Dev, Staging & Production Workflow with Gitify (at MODXpo 2015 in Munich)

What is a Dev/Stage/Production Workflow?

• One site or project

• Replicated across separated environments, each potentially in a completely different state

Page 5: Dev, Staging & Production Workflow with Gitify (at MODXpo 2015 in Munich)

What is a Dev/Stage/Production Workflow?

• One site or project

• Replicated across separated environments, each potentially in a completely different state

• Tailored to the team, environment or business processes

Page 6: Dev, Staging & Production Workflow with Gitify (at MODXpo 2015 in Munich)

modx.com

/blog/2015/11/16/your-website-just-got-a-prom

otion/

Page 7: Dev, Staging & Production Workflow with Gitify (at MODXpo 2015 in Munich)

Requirements for a workflow that actually works

Page 8: Dev, Staging & Production Workflow with Gitify (at MODXpo 2015 in Munich)

Requirements for a workflow that actually works

• Automation

Page 9: Dev, Staging & Production Workflow with Gitify (at MODXpo 2015 in Munich)

Requirements for a workflow that actually works

• Automation

• Automation

Page 10: Dev, Staging & Production Workflow with Gitify (at MODXpo 2015 in Munich)

Requirements for a workflow that actually works

• Automation

• Automation

• str_repeat(‘Automation’, PHP_INT_MAX);

Page 11: Dev, Staging & Production Workflow with Gitify (at MODXpo 2015 in Munich)

Requirements for a workflow that actually works

• Automation

• Automation

• str_repeat(‘Automation’, PHP_INT_MAX);

• Accessible to the different stakeholders

Page 12: Dev, Staging & Production Workflow with Gitify (at MODXpo 2015 in Munich)

Requirements for a workflow that actually works

• Automation

• Automation

• str_repeat(‘Automation’, PHP_INT_MAX);

• Accessible to the different stakeholders

• Easy to rollback

Page 13: Dev, Staging & Production Workflow with Gitify (at MODXpo 2015 in Munich)

Requirements for a workflow that actually works

• Automation

• Automation

• str_repeat(‘Automation’, PHP_INT_MAX);

• Accessible to the different stakeholders

• Easy to rollback

• Able of dealing with conflicting changes

Page 14: Dev, Staging & Production Workflow with Gitify (at MODXpo 2015 in Munich)

To be able of replicating environments and automating a

workflow, you need a single source of truth.

Page 15: Dev, Staging & Production Workflow with Gitify (at MODXpo 2015 in Munich)

How to deal with all of this?

Page 16: Dev, Staging & Production Workflow with Gitify (at MODXpo 2015 in Munich)

How to deal with all of this?

Git!

Page 17: Dev, Staging & Production Workflow with Gitify (at MODXpo 2015 in Munich)

How to deal with all of this?

Git!

• Manages state of files

Page 18: Dev, Staging & Production Workflow with Gitify (at MODXpo 2015 in Munich)

How to deal with all of this?

Git!

• Manages state of files

• Can handle conflicts automatically + manually

Page 19: Dev, Staging & Production Workflow with Gitify (at MODXpo 2015 in Munich)

How to deal with all of this?

Git!

• Manages state of files

• Can handle conflicts automatically + manually

• Easy to automate through simple CLI api

Page 20: Dev, Staging & Production Workflow with Gitify (at MODXpo 2015 in Munich)

How to deal with all of this?

Git!

• Manages state of files

• Can handle conflicts automatically + manually

• Easy to automate through simple CLI api

• Can be made more accessible through GUI clients and services (like GitHub)

Page 21: Dev, Staging & Production Workflow with Gitify (at MODXpo 2015 in Munich)

To be able of replicating environments and automating a

workflow, the git repository needs to be the single source of truth.

Page 22: Dev, Staging & Production Workflow with Gitify (at MODXpo 2015 in Munich)

How to deal with all of this…on a MODX project?

Page 23: Dev, Staging & Production Workflow with Gitify (at MODXpo 2015 in Munich)

How to deal with all of this…on a MODX project?

• Store assets, custom components and relevant files in git

Page 24: Dev, Staging & Production Workflow with Gitify (at MODXpo 2015 in Munich)

How to deal with all of this…on a MODX project?

• Store assets, custom components and relevant files in git

• … missing the important bits!

• Content

• Elements (templates, TVs, chunks, snippets, plugins)

• Other information stored in the database

Page 25: Dev, Staging & Production Workflow with Gitify (at MODXpo 2015 in Munich)

How do we get information in our database into a

format that unlocks the potential of git?

Page 26: Dev, Staging & Production Workflow with Gitify (at MODXpo 2015 in Munich)

Gitify!

Page 27: Dev, Staging & Production Workflow with Gitify (at MODXpo 2015 in Munich)
Page 28: Dev, Staging & Production Workflow with Gitify (at MODXpo 2015 in Munich)

What is Gitify?

• Command line toolkit

• Written with Symfony 2 Console

Page 29: Dev, Staging & Production Workflow with Gitify (at MODXpo 2015 in Munich)

What can Gitify do?

Page 30: Dev, Staging & Production Workflow with Gitify (at MODXpo 2015 in Munich)

What can Gitify do?

• Write information from the database to files

Gitify extract

Page 31: Dev, Staging & Production Workflow with Gitify (at MODXpo 2015 in Munich)

What can Gitify do?

• Write information from the database to files

Gitify extract

• Write information from those files into the database

Gitify build

Page 32: Dev, Staging & Production Workflow with Gitify (at MODXpo 2015 in Munich)
Page 33: Dev, Staging & Production Workflow with Gitify (at MODXpo 2015 in Munich)

Built-in magic

Page 34: Dev, Staging & Production Workflow with Gitify (at MODXpo 2015 in Munich)

Built-in magic

• Automatic ID conflict resolution

Page 35: Dev, Staging & Production Workflow with Gitify (at MODXpo 2015 in Munich)

Built-in magic

• Automatic ID conflict resolution

• Automatic orphan cleanup

Page 36: Dev, Staging & Production Workflow with Gitify (at MODXpo 2015 in Munich)

Gitify bridges the gap between the database and

your git repository

Page 37: Dev, Staging & Production Workflow with Gitify (at MODXpo 2015 in Munich)

Project Configuration

• .gitify file in root of project

• Specifies data

• Specifies packages to install

Page 38: Dev, Staging & Production Workflow with Gitify (at MODXpo 2015 in Munich)
Page 39: Dev, Staging & Production Workflow with Gitify (at MODXpo 2015 in Munich)
Page 40: Dev, Staging & Production Workflow with Gitify (at MODXpo 2015 in Munich)

So how does the workflow work?

Page 41: Dev, Staging & Production Workflow with Gitify (at MODXpo 2015 in Munich)

Different environments have different workflow needs.

Page 42: Dev, Staging & Production Workflow with Gitify (at MODXpo 2015 in Munich)

Putting it together

Git - develop - staging - production

localhost

stage.site.com

site.com

Page 43: Dev, Staging & Production Workflow with Gitify (at MODXpo 2015 in Munich)

Dev Workflow

Make changes in MODX

Run `Gitify extract`Commit to repository

and push

Page 44: Dev, Staging & Production Workflow with Gitify (at MODXpo 2015 in Munich)

File-based Dev WorkflowMake changes in Data Files

Run `Gitify build`

Test changes in MODX

Commit to repository and push

Page 45: Dev, Staging & Production Workflow with Gitify (at MODXpo 2015 in Munich)

Putting it together

Git - develop - staging - production

localhost

stage.site.com

site.com

manual

Page 46: Dev, Staging & Production Workflow with Gitify (at MODXpo 2015 in Munich)

Staging WorkflowEditor team makes

content changes in MODX

Automatically extracted

Automatically committed to staging branch

Automatically pushed

Page 47: Dev, Staging & Production Workflow with Gitify (at MODXpo 2015 in Munich)

Putting it together

Git - develop - staging - production

localhost

stage.site.com

site.com

manual

automated

Page 48: Dev, Staging & Production Workflow with Gitify (at MODXpo 2015 in Munich)

Production Workflow

Don’t make changes on production

Page 49: Dev, Staging & Production Workflow with Gitify (at MODXpo 2015 in Munich)

Production Workflow

Don’t make changes on production(or use the same workflow as staging if you must)

Page 50: Dev, Staging & Production Workflow with Gitify (at MODXpo 2015 in Munich)

Production Workflow

Don’t make changes on production(or use the same workflow as staging if you must)

(but really, you shouldn’t)

Page 51: Dev, Staging & Production Workflow with Gitify (at MODXpo 2015 in Munich)

Setting automatic deployments

Page 52: Dev, Staging & Production Workflow with Gitify (at MODXpo 2015 in Munich)
Page 53: Dev, Staging & Production Workflow with Gitify (at MODXpo 2015 in Munich)

Deploying with Gitify

• git fetch origin• git reset --hard %COMMIT%• git pull origin %BRANCH%• Gitify backup deploy_%TIMESTAMP_UTC%• # Gitify package:install --all• Gitify build

Page 54: Dev, Staging & Production Workflow with Gitify (at MODXpo 2015 in Munich)

Creating new environments

Page 55: Dev, Staging & Production Workflow with Gitify (at MODXpo 2015 in Munich)

Creating new environments

1. Clone the repository

Page 56: Dev, Staging & Production Workflow with Gitify (at MODXpo 2015 in Munich)

Creating new environments

1. Clone the repository

2. Install MODX (Gitify modx:install)

Page 57: Dev, Staging & Production Workflow with Gitify (at MODXpo 2015 in Munich)

Creating new environments

1. Clone the repository

2. Install MODX (Gitify modx:install)

3. Install dependent packages (Gitify package:install —all)

Page 58: Dev, Staging & Production Workflow with Gitify (at MODXpo 2015 in Munich)

Creating new environments

1. Clone the repository

2. Install MODX (Gitify modx:install)

3. Install dependent packages (Gitify package:install —all)

4. Build the data (Gitify build [--force])

Page 59: Dev, Staging & Production Workflow with Gitify (at MODXpo 2015 in Munich)

Putting it together

Git - develop - staging - production

localhost

stage.site.com

site.com

manual

automated

automated

Page 60: Dev, Staging & Production Workflow with Gitify (at MODXpo 2015 in Munich)

But how do we automatically extract,

commit and push?

Page 61: Dev, Staging & Production Workflow with Gitify (at MODXpo 2015 in Munich)

Introducing Gitify Watch

Page 62: Dev, Staging & Production Workflow with Gitify (at MODXpo 2015 in Munich)
Page 63: Dev, Staging & Production Workflow with Gitify (at MODXpo 2015 in Munich)

X

Page 64: Dev, Staging & Production Workflow with Gitify (at MODXpo 2015 in Munich)

Gitify Watch

Page 65: Dev, Staging & Production Workflow with Gitify (at MODXpo 2015 in Munich)

Gitify Watch

• Works with Scheduler

Page 66: Dev, Staging & Production Workflow with Gitify (at MODXpo 2015 in Munich)

Gitify Watch

• Works with Scheduler

• Triggers on saving resources and elements

Page 67: Dev, Staging & Production Workflow with Gitify (at MODXpo 2015 in Munich)

Gitify Watch

• Works with Scheduler

• Triggers on saving resources and elements

• Automatically extracts, commits & pushes data

Page 68: Dev, Staging & Production Workflow with Gitify (at MODXpo 2015 in Munich)
Page 69: Dev, Staging & Production Workflow with Gitify (at MODXpo 2015 in Munich)
Page 70: Dev, Staging & Production Workflow with Gitify (at MODXpo 2015 in Munich)

Gitify Watch

Page 72: Dev, Staging & Production Workflow with Gitify (at MODXpo 2015 in Munich)

Gitify Watch

• Free

• github.com/modmore/GitifyWatch

Page 73: Dev, Staging & Production Workflow with Gitify (at MODXpo 2015 in Munich)

Gitify Watch

• Free

• github.com/modmore/GitifyWatch

• Package via modmore.com before holidays

Page 74: Dev, Staging & Production Workflow with Gitify (at MODXpo 2015 in Munich)

Gitify can do more!

Page 75: Dev, Staging & Production Workflow with Gitify (at MODXpo 2015 in Munich)

Install & Upgrade MODXGitify modx:install [version]

Gitify modx:upgrade [version]

Page 76: Dev, Staging & Production Workflow with Gitify (at MODXpo 2015 in Munich)

Install MODX packagesGitify package:install [name] [--version]

Page 77: Dev, Staging & Production Workflow with Gitify (at MODXpo 2015 in Munich)

Backup & RestoreGitify backup [name] Gitify restore [name]

Page 78: Dev, Staging & Production Workflow with Gitify (at MODXpo 2015 in Munich)

Links & More Info

• Source: github.com/modmore/Gitify

• Docs: github.com/modmore/Gitify/wiki and modmore.github.io/Gitify/

• GitifyWatch: github.com/modmore/GitifyWatch

• Example Gitify projects:

• github.com/modmore/MODX.today

• github.com/modmore/demo.modmore.com

Page 79: Dev, Staging & Production Workflow with Gitify (at MODXpo 2015 in Munich)

Thank you@mark_hamstra - @modmore

markhamstra.com - modmore.com