Upgrade to Pro — share decks privately, control downloads, hide ads and more …

A Workflow for Collaboration, Quick Fixes, and Reliable Deployment

Kevin Smith
October 07, 2015

A Workflow for Collaboration, Quick Fixes, and Reliable Deployment

You’ve spent all this time working on a new site or piece of software, so what do you do when it comes time for launch? Kevin shows how to use a version control system like Git to collaborate with a team, separate environments for development, testing, and production, and tools to easily deploy code changes to testing and production environments.

Kevin Smith

October 07, 2015
Tweet

More Decks by Kevin Smith

Other Decks in Technology

Transcript

  1. @_KevinSmith Hearsay Interactive 17 Years in Web Technologies
 7 Years

    Full-Time Experience · Director of Services @ EllisLab
 Senior Developer @ Caddis · Independent Consultant
 through Hearsay Interactive · ExpressionEngine, Laravel, CodeIgniter, & custom PHP • Front-End Development • PHP-based
 Backend/API Development • Database Management • Apache & nginx Administration • Development Strategy • Deployment Strategy Kevin Smith 2 Full-Stack Developer
  2. @_KevinSmith Hearsay Interactive 8 You Need Distinct Environments Freedom to

    make mistakes. linode.com digitalocean.com forge.laravel.com Staging & Production Environments
  3. @_KevinSmith Hearsay Interactive Multi- Environment Configuration ExpressionEngine
 FocusLab’s EE Master

    Config
 github.com/focuslabllc/ee-master-config WordPress
 Studio 24 WordPress Multi-Environment Config
 github.com/studio24/wordpress-multi-env- config Craft
 Built-in
 buildwithcraft.com/docs/multi-environment- configs PHP dotenv
 composer package
 github.com/vlucas/phpdotenv 9
  4. @_KevinSmith Hearsay Interactive “…you won't find a top programmer, web

    developer, or web designer who doesn't use version control.” - Learn Version Control with Git
 http://www.git-tower.com/learn 11 We’re professionals.
  5. @_KevinSmith Hearsay Interactive Work together without stepping on toes. Git

    12 Use a decentralized version control system like Git Image credit: https://www.atlassian.com/git/tutorials/setting-up-a-repository/git-clone
  6. @_KevinSmith Hearsay Interactive Work together without stepping on toes. 13

    Take complete project snapshots at any time Image credit: https://git-scm.com/book/en/v2/Getting-Started-Git-Basics Git
  7. @_KevinSmith Hearsay Interactive Work together without stepping on toes. 14

    Create branches to develop features separately Image credit: https://git-scm.com/about Git
  8. @_KevinSmith Hearsay Interactive Work together without stepping on toes. 15

    Perform code reviews Image credit: https://blog.mozilla.org/webdev/2011/11/21/git-using-topic-branches-and-interactive-rebasing-effectively/ Git
  9. @_KevinSmith Hearsay Interactive Git Flow A branching model introduced by

    Vincent Driessen
 http://nvie.com/posts/a-successful-git-branching-model Clear workflow for • Feature development • Staging next release • Releasing to Production • Hot fixing critical Production issues 17
  10. @_KevinSmith Hearsay Interactive Git Flow: The Main Branches The Master

    Branch
 HEAD @ origin/master always reflects production-ready state Code changes always ready to be deployed to Production 
 The Develop Branch
 HEAD @ origin/develop always reflects latest code changes ready for next release Code always auto-deployed to Staging 18
  11. @_KevinSmith Hearsay Interactive Git Flow: The Supporting Branches Feature, Release,

    and Hotfix branches Aid in parallel development Make feature tracking clear Help prepare for production releases Ease quick fixes for live site issues Temporary: removed after merging into main branches 19
  12. @_KevinSmith Hearsay Interactive May branch off from: develop
 Must merge

    back into: develop
 Naming convention: feature/*
 Example: feature/my-new-feature Used to develop new features for a future release. A single project will often have many feature branches at once. Delete branch after final merge back into develop branch. Git Flow:
 Feature Branches 20 Image credit: http://nvie.com/posts/a-successful-git-branching-model/
  13. @_KevinSmith Hearsay Interactive Must branch off from: develop
 Must merge

    back into: develop and master
 Naming convention: release/*
 Example: release/v1.0 Supports prep of production release. No new features. Crossing off items on release checklist. Create branch when release countdown begins. Tag commit, merge in, and delete branch upon release. Git Flow:
 Release Branches 21
  14. @_KevinSmith Hearsay Interactive The Cardinal Rule Never Ever, EVER change

    code directly in Staging or Production. Ever. 22
  15. @_KevinSmith Hearsay Interactive Must branch off from: master
 Must merge

    back into: develop and master
 Naming convention: hotfix/*
 Example: hotfix/white-screen-of-death Used to fix critical issues in Production. Narrowly focused on the necessary fix. Git Flow:
 Hotfix Branches 23 Image credit: http://nvie.com/posts/a-successful-git-branching-model/
  16. @_KevinSmith Hearsay Interactive 24 Time release branches master develop hotfixes

    feature branches Feature for future release Tag 1.0 Major feature for next release From this point on, “next release” means the release after 1.0 Severe bug fixed for production: hotfix 0.2 Bugfixes from rel. branch may be continuously merged back into develop Tag 0.1 Tag 0.2 Incorporate bugfix in develop Only bugfixes! Start of release branch for 1.0 Author: Vincent Driessen Original blog post: http://nvie.com/archives/323 License: Creative Commons
  17. @_KevinSmith Hearsay Interactive Git Flow Tools 25 $ git flow

    feature start my-new-feature $ git flow feature finish my-new-feature $ git flow hotfix start php-errors $ git flow hotfix finish php-errors $ git flow release start v2.0 $ git flow release finish v2.0
  18. @_KevinSmith Hearsay Interactive Automate as much of your menial, routine

    tasks as you can Especially automate where consistency is important Automated deployment ensures code changes… • Made quickly • Where expected • With an audit trail Getting code changes from Development to Staging & Production Deployment 27
  19. @_KevinSmith Hearsay Interactive Deploying to Staging Automatically triggered by
 push

    to origin/develop Deploying to Production Manually triggered by human who
 has notified project stakeholders
 and will be around in case of fire Getting code changes from Development to Staging & Production Deployment 28
  20. @_KevinSmith Hearsay Interactive Run composer install Bust Caches Rebuild Caches

    Rename or Remove Files Copy Environment-specific Files Run Database Migrations Send Notifications to HipChat, Basecamp, etc. Pre- and Post-Deploy Hooks 34 Automate the menial things.
  21. @_KevinSmith Hearsay Interactive Speeds Development Reserves Your Energy to Focus

    on Real Problems Frees You to Fail Early and Often Gives You a Safe Place to Make Mistakes 36
  22. @_KevinSmith Hearsay Interactive Improves Collaboration Dramatically Reduces Team Confusion Provides

    Visibility into Others’ Progress Avoids Code Collisions Gives Confidence in Staging & Production 37
  23. @_KevinSmith Hearsay Interactive Future You Will Thank Present You You

    + 1 Year Will Forget A Lot of Things Reliable, Consistent Process Gives You Bearings When Staging & Production in Expected State,
 Hit the Ground Running 38
  24. @_KevinSmith Hearsay Interactive 40 Thanks! Slides up now at speakerdeck.com/kevinsmith

    or follow @_KevinSmith
 on Twitter for the link Need my help on a project? [email protected]