dev, staging & production workflow with gitify (at modxpo 2015 in munich)
TRANSCRIPT
Dev, Staging & Production Workflow with Gitify
Mark Hamstra, @mark_hamstra
What is a Dev/Stage/Production Workflow?
What is a Dev/Stage/Production Workflow?
• One site or project
What is a Dev/Stage/Production Workflow?
• One site or project
• Replicated across separated environments, each potentially in a completely different state
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
modx.com
/blog/2015/11/16/your-website-just-got-a-prom
otion/
Requirements for a workflow that actually works
Requirements for a workflow that actually works
• Automation
Requirements for a workflow that actually works
• Automation
• Automation
Requirements for a workflow that actually works
• Automation
• Automation
• str_repeat(‘Automation’, PHP_INT_MAX);
Requirements for a workflow that actually works
• Automation
• Automation
• str_repeat(‘Automation’, PHP_INT_MAX);
• Accessible to the different stakeholders
Requirements for a workflow that actually works
• Automation
• Automation
• str_repeat(‘Automation’, PHP_INT_MAX);
• Accessible to the different stakeholders
• Easy to rollback
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
To be able of replicating environments and automating a
workflow, you need a single source of truth.
How to deal with all of this?
How to deal with all of this?
Git!
How to deal with all of this?
Git!
• Manages state of files
How to deal with all of this?
Git!
• Manages state of files
• Can handle conflicts automatically + manually
How to deal with all of this?
Git!
• Manages state of files
• Can handle conflicts automatically + manually
• Easy to automate through simple CLI api
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)
To be able of replicating environments and automating a
workflow, the git repository needs to be the single source of truth.
How to deal with all of this…on a MODX project?
How to deal with all of this…on a MODX project?
• Store assets, custom components and relevant files in git
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
How do we get information in our database into a
format that unlocks the potential of git?
Gitify!
What is Gitify?
• Command line toolkit
• Written with Symfony 2 Console
What can Gitify do?
What can Gitify do?
• Write information from the database to files
Gitify extract
What can Gitify do?
• Write information from the database to files
Gitify extract
• Write information from those files into the database
Gitify build
Built-in magic
Built-in magic
• Automatic ID conflict resolution
Built-in magic
• Automatic ID conflict resolution
• Automatic orphan cleanup
Gitify bridges the gap between the database and
your git repository
Project Configuration
• .gitify file in root of project
• Specifies data
• Specifies packages to install
So how does the workflow work?
Different environments have different workflow needs.
Putting it together
Git - develop - staging - production
localhost
stage.site.com
site.com
Dev Workflow
Make changes in MODX
Run `Gitify extract`Commit to repository
and push
File-based Dev WorkflowMake changes in Data Files
Run `Gitify build`
Test changes in MODX
Commit to repository and push
Putting it together
Git - develop - staging - production
localhost
stage.site.com
site.com
manual
Staging WorkflowEditor team makes
content changes in MODX
Automatically extracted
Automatically committed to staging branch
Automatically pushed
Putting it together
Git - develop - staging - production
localhost
stage.site.com
site.com
manual
automated
Production Workflow
Don’t make changes on production
Production Workflow
Don’t make changes on production(or use the same workflow as staging if you must)
Production Workflow
Don’t make changes on production(or use the same workflow as staging if you must)
(but really, you shouldn’t)
Setting automatic deployments
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
Creating new environments
Creating new environments
1. Clone the repository
Creating new environments
1. Clone the repository
2. Install MODX (Gitify modx:install)
Creating new environments
1. Clone the repository
2. Install MODX (Gitify modx:install)
3. Install dependent packages (Gitify package:install —all)
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])
Putting it together
Git - develop - staging - production
localhost
stage.site.com
site.com
manual
automated
automated
But how do we automatically extract,
commit and push?
Introducing Gitify Watch
X
Gitify Watch
Gitify Watch
• Works with Scheduler
Gitify Watch
• Works with Scheduler
• Triggers on saving resources and elements
Gitify Watch
• Works with Scheduler
• Triggers on saving resources and elements
• Automatically extracts, commits & pushes data
Gitify Watch
Gitify Watch
• Free
• github.com/modmore/GitifyWatch
Gitify Watch
• Free
• github.com/modmore/GitifyWatch
• Package via modmore.com before holidays
Gitify can do more!
Install & Upgrade MODXGitify modx:install [version]
Gitify modx:upgrade [version]
Install MODX packagesGitify package:install [name] [--version]
Backup & RestoreGitify backup [name] Gitify restore [name]
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
Thank you@mark_hamstra - @modmore
markhamstra.com - modmore.com