Slide 1

Slide 1 text

Using Git to Manage Deployments: David Kinzer

Slide 2

Slide 2 text

● General overview of deployment. ● Some Drupal specific considerations. ● Walk through 2 part demo of technique. ● Some summary statements. ● Answer questions (but feel free to interrupt). Introduction

Slide 3

Slide 3 text

Some basic terms: Git - we all love this wonderful little tool. Commits - Are the way to save changes. Push/Pull - Is how we share commits. Deploy - In a second... Drupal - Is a PHP CMS/Framework for building web apps.

Slide 4

Slide 4 text

Relax, it’s all good.

Slide 5

Slide 5 text

Unless you don’t version control.

Slide 6

Slide 6 text

DEPLOYMENT?

Slide 7

Slide 7 text

There are so many steps… > LAMP stack. > Development... > Testing... > Deployment

Slide 8

Slide 8 text

No content

Slide 9

Slide 9 text

No content

Slide 10

Slide 10 text

A deployment, of sorts.

Slide 11

Slide 11 text

There are many ways to solve this...

Slide 12

Slide 12 text

Here’s one way... > cd project > touch project.tgz && tar -czvf project.tgz . > scp project.tgz somehost.com:~/project.tgz > ssh somehost.com ‘tar xvf project.tgz -C www \ && rm project.tgz && chmod 755 -R www’

Slide 13

Slide 13 text

Makefile ---------------- deploy: bash bin/deploy.sh A little bit better might be... bin/deploy.sh ------------------ #!/bin/bash tar… scp … ssh ...

Slide 14

Slide 14 text

> vagrant up

Slide 15

Slide 15 text

> git pull origin master? … Sure this can move our files, but what about any Drupal specific consideration? But what about plain old git pull?

Slide 16

Slide 16 text

What’s Drupal Specific Here... ● Any database changes… ● Enabling disabling modules… ● Configuration changes… ● Caches...

Slide 17

Slide 17 text

No content

Slide 18

Slide 18 text

Drush to the rescue!!! ● drush updb ● drush cc all ● many other goodies...

Slide 19

Slide 19 text

Makefile ---------------- deploy: bash bin/deploy.sh Another approach might be... bin/deploy.sh ------------------ #!/bin/bash cd project git pull… # plus some drush magic.. drush updb drush cc all

Slide 20

Slide 20 text

The ultimate magic is invocation... > git push

Slide 21

Slide 21 text

Git Supports Hooks. .git/hooks ├── applypatch-msg ├── commit-msg ├── post-update ├── pre-applypatch ├── pre-commit ├── prepare-commit-msg ├── pre-rebase └── update

Slide 22

Slide 22 text

First way… > git clone --bare project > cd project.git/hooks/ > vi post-update > cd - > git clone project.git dev > cd dev && “make changes” > git push Prepare the repos... Second Way… > git clone live dev > cd project/.git/hooks > vi post-update… (caveat) > cd ../.. > git config \ receive.denycurrentbranch false > ...

Slide 23

Slide 23 text

To Bare or not to Bare... NOT bare is better IMHO because you can version control repo preparation and deployment script with the project….

Slide 24

Slide 24 text

DEMO TIME In 2 parts

Slide 25

Slide 25 text

We can invoke whatever power... Docker Vagrant Whatever

Slide 26

Slide 26 text

So, what to choose? This decision is guided by need.

Slide 27

Slide 27 text

No content

Slide 28

Slide 28 text

Any solution can benefit... > git push

Slide 29

Slide 29 text

Remember, relax, it’s all good. David Kinzer Jenkins Law Library twitter/dtkinzer github/dkinzer

Slide 30

Slide 30 text

Photos/Illustrations Credits... ● "Man Fig Miniature Wave Sit Rest Relax Friendly", by Anja Osenberg, CC0 1.0 ● "36100 Bangladesh Air Force MIG-29 Landing with the Drogue Parachute Deployed", by Fisal Akram, CC BY-SA 2.0 ● "Parachutist Skydiver Skydiving Sky Parachute", by Lynn Greyling, CC0 1.0 ● "Grow Blossom Time Lapse Sequence Amaryllis Flower", by Stefan Schweihofer, CC0 1.0 ● "Puzzle Cube Wood Block Toys Wooden Toys Build", by Hans Braxmeier, CC0 1.0 ● "Magic", by Bart Cayusa, CC BY-SA 2.0 ● "Simple Drupal Wallpaper", by Matt Farina, CC BY-SA 2.0 ● "Problem Shield Note Street Sign Road Sign Sky", by Gerd Altmann, CC0 1.0 ● "Drush Logo", by Dan Morrison, GPL V2 ● "An Illustration to the Markandeya Purana: The Gods invoke Devi Estimate", by Unknown, Public Domain ● "Livarna", by Viktorija Rozman, CC BY-SA 3.0 ● "Bare Feet Foot Tanned Brown Hair Water", by Public Domain Pictures, CC0 1.0 ● "Cattleman NM55 Revolver Sketch", by Don Stewart, CC BY-SA 2.0 ● "Control!", by Faramarz Hashemi, CC BY-SA 2.0 ● "Flight Controls", by Bryan Burke, CC BY-NC-ND 2.0

Slide 31

Slide 31 text

Please fork my demo.

Slide 32

Slide 32 text

I’ll git pull yours, if you git pull mine.

Slide 33

Slide 33 text

This repo’s off the hook.

Slide 34

Slide 34 text

More Credits... ● "Canon 550d - Snail on Fork", Doug Wheller (@Doug88888), CC BY-SA 2.0 ● "P as in pull", by Kristina Alexanderson (@cclones), CC BY-SA 2.0