Successfully reported this slideshow.
Your SlideShare is downloading. ×

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

More Related Content

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

  1. 1. Solving the Workflow or how MODX.today is being managed across 3 servers with Git & Gitify
  2. 2. Who am I?! Mark Hamstra Founder & CEA at modmore Freelance MODX Developer Not me Turbo Bommel
  3. 3. Solving the Workflow Introducing the project: MODX.today Introducing the tools: Gitify & Git Putting it together: designing a Workflow Setting up automatic deployments
  4. 4. What is MODX.today?
  5. 5. 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
  6. 6. github.com/modmore/MODX.today
  7. 7. Solving the Workflow Introducing the project: MODX.today Introducing the tools: Gitify & Git Putting it together: designing a Workflow Setting up automatic deployments
  8. 8. What is Gitify?
  9. 9. 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
  10. 10. But, Gitify is… • A useful addition to your toolkit • Flexible to mix & match with other tools • Built on top of Symfony2 Console • Open source!
  11. 11. 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)
  12. 12. 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
  13. 13. Running Gitify
  14. 14. $ Gitify init • Sets up a new Gitify configuration file interactively. • --overwrite flag allows you to create a new config file if one already exists.
  15. 15. .gitify file data_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
  16. 16. $ 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
  17. 17. 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]]
  18. 18. • 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
  19. 19. 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
  20. 20. $ 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.
  21. 21. $ 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.
  22. 22. $ Gitify backup • Creates a backup of your MySQL database using mysqldump • [name] the filename for the backup file
  23. 23. $ 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.
  24. 24. Solving the Workflow Introducing the project: MODX.today Introducing the tools: Gitify & Git Putting it together: designing a Workflow Setting up automatic deployments
  25. 25. The Workflow Git Repository
  26. 26. The Workflow Git Repository develop production staging
  27. 27. The Workflow site.com Git Repository site.dev staging.site.com develop production staginggit push git pull gitpush gitpull git pull
  28. 28. The Workflow site.com Git Repository site.dev staging.site.com develop production staging git merge git merge
  29. 29. The Workflow site.com Git Repository staging.site.com develop production staging site.dev Commit Changes to Git Synchronise with Git Repository Gitify extract Build stuff in MODX Gitify build
  30. 30. The Workflow site.com Git Repository staging.site.com develop production staging Commit Changes to Git Synchronise with Git Repository (Gitify extract) Make a Change in Gitify Files Gitify build Test changes site.dev
  31. 31. The Workflow site.com Git Repository site.dev staging.site.com develop production staging
  32. 32. The Workflow site.com Git Repository site.dev develop production staging Gitify Watch Schedules Extract Make change in MODX staging.site.com Gitify extract git add -a git commit gitpush
  33. 33. The Workflow site.com Git Repository site.dev staging.site.com develop production staging
  34. 34. The Workflow site.com Git Repository site.dev staging.site.com develop production staging deploy
  35. 35. Solving the Workflow Introducing the project: MODX.today Introducing the tools: Gitify & Git Putting it together: designing a Workflow Setting up automatic deployments
  36. 36. 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)
  37. 37. 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)
  38. 38. 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`;
  39. 39. Handling Automatic Deploys (#2) • Use a CI / Deployment service / tool: dploy.io
  40. 40. The End Useful links:
 • MODX.today • MODX.today/submit • github.com/modmore/Gitify • github.com/modmore/Gitify/wiki/Home • github.com/modmore/MODX.today

×