SlideShare una empresa de Scribd logo
1 de 12
Descargar para leer sin conexión
Deploy easily!
with
Igor Santos
Web developer
● From Rio de Janeiro, Brazil
● PHP Developer for ~6 years
● Ruby and JS Developer for fun
● Playing around with git for ~2 years
slideshare.net/igorsantos07
0. Introduction
● Knows what Git is?
● Have ever used Git in the command line?
● Have ever deployed code?
○ How? SCP? WGet?
● Anyone developing in the production server?
1. Git Basics
● Commit: Saves changes with a description
● Pull: Get commits from a server
● Push: Send commits to a server
● Remotes
○ A remote machine that has a copy of the repository
and accepts your commits
○ In a common centralized organization you usually
have one, but it's possible to have many
○ Example: main repo is BitBucket or Google Code,
mirrored to GitHub
2. Configure your server
igor@local$ ssh santos@bluenose.cs.dal.ca
password: **********
santos@bluenose$ mkdir repos
santos@bluenose$ cd repos
santos@bluenose$ pwd
/users/cs/santos/repos
santos@bluenose$ git clone «repo» myRep --bare
This creates a clone of that repository that works just as
another repository: with all administrative data, but not
useable for development, as the code is not really checked
in - just the Git meta-data.
Take note
igor@local$ cd dev/myCode
igor@local$ git remote add prod
ssh://santos@bluenose.cs.dal.ca:/users/cs/santos/repos/myRep
igor@local$ "Hi there!" > README.mkd
igor@local$ git commit "+ Adding readme"
igor@local$ git push prod
2. Configure your server
Name given to the remote server
Complete repository URL
No line break!
igor@local$ git commit "+ Adding readme"
igor@local$ git push prod
Q: OK, so... where's my README file?
A: In the repository!
Q: I can't see it. «not really a question»
2. Configure your server
3. Git Hooks
● 2 types: client and server hooks
● Client:
○ pre/post-commit
○ [prepare-]commit-msg
○ post-checkout, post-merge
● Server:
○ pre/post-receive Once per push
○ update Once per pushed branch
http://git-scm.com/book/en/Customizing-Git-Git-Hooks
3. Git Hooks
Simple copy
$ cat hooks/post-receive
#!/bin/sh
GIT_WORK_TREE=/var/www/mysite git checkout -f
Opposite of git clone --bare: copies the entire repository
code, without git data. By default does that with the master
branch, but you can use other options here as well.
GIT_WORK_TREE tells git where it would copy stuff.
3. Git Hooks
Complete deployment script
https://bitbucket.org/igorsantos07/calen-do/src/3fea92ee46c1/git-hooks/update
4. Advanced ideas
GitHub and other Git online repositories
have options to do HTTP requests with code
information after pushes, similar to post-
receive hooks. This data can be used to
trigger a deployment script in the server.
There's also an online service called
DeployHQ, where you can configure any
repository (SVN/Git/Hg) and many deploy
methods (FTP/SFTP/S3/Rackspace).
It deploys new code using the chosen method.
4. Adv.
ideas
deployhq.com

Más contenido relacionado

La actualidad más candente

A successful Git branching model
A successful Git branching model A successful Git branching model
A successful Git branching model abodeltae
 
FOSDEM 2017: GitLab CI
FOSDEM 2017:  GitLab CIFOSDEM 2017:  GitLab CI
FOSDEM 2017: GitLab CIOlinData
 
Git extension-training
Git extension-trainingGit extension-training
Git extension-trainingEric Guo
 
Using GitLab CI
Using GitLab CIUsing GitLab CI
Using GitLab CIColCh
 
GitFlow, SourceTree and GitLab
GitFlow, SourceTree and GitLabGitFlow, SourceTree and GitLab
GitFlow, SourceTree and GitLabShinu Suresh
 
Docker introduction in Hardware Company
Docker introduction in Hardware CompanyDocker introduction in Hardware Company
Docker introduction in Hardware CompanyEvan Lin
 
Write microservice in golang
Write microservice in golangWrite microservice in golang
Write microservice in golangBo-Yi Wu
 
Breaking Bad Habits with GitLab CI
Breaking Bad Habits with GitLab CIBreaking Bad Habits with GitLab CI
Breaking Bad Habits with GitLab CIIvan Nemytchenko
 
A painless self-hosted Git service: Gitea
A painless self-hosted Git service: GiteaA painless self-hosted Git service: Gitea
A painless self-hosted Git service: GiteaBo-Yi Wu
 
Jenkins to Gitlab - Intelligent Build-Pipelines
Jenkins to Gitlab - Intelligent Build-PipelinesJenkins to Gitlab - Intelligent Build-Pipelines
Jenkins to Gitlab - Intelligent Build-PipelinesChristian Münch
 
Git introduction for Beginners
Git introduction for BeginnersGit introduction for Beginners
Git introduction for BeginnersMortezaTaghaddomi
 

La actualidad más candente (20)

A successful Git branching model
A successful Git branching model A successful Git branching model
A successful Git branching model
 
Git and git flow
Git and git flowGit and git flow
Git and git flow
 
Subversion to Git Migration
Subversion to Git MigrationSubversion to Git Migration
Subversion to Git Migration
 
FOSDEM 2017: GitLab CI
FOSDEM 2017:  GitLab CIFOSDEM 2017:  GitLab CI
FOSDEM 2017: GitLab CI
 
Juc boston2014.pptx
Juc boston2014.pptxJuc boston2014.pptx
Juc boston2014.pptx
 
Git flow
Git flowGit flow
Git flow
 
Git best practices workshop
Git best practices workshopGit best practices workshop
Git best practices workshop
 
Git extension-training
Git extension-trainingGit extension-training
Git extension-training
 
Git best practices 2016
Git best practices 2016Git best practices 2016
Git best practices 2016
 
Git
GitGit
Git
 
Using GitLab CI
Using GitLab CIUsing GitLab CI
Using GitLab CI
 
Git workflows
Git workflowsGit workflows
Git workflows
 
GitFlow, SourceTree and GitLab
GitFlow, SourceTree and GitLabGitFlow, SourceTree and GitLab
GitFlow, SourceTree and GitLab
 
Git
GitGit
Git
 
Docker introduction in Hardware Company
Docker introduction in Hardware CompanyDocker introduction in Hardware Company
Docker introduction in Hardware Company
 
Write microservice in golang
Write microservice in golangWrite microservice in golang
Write microservice in golang
 
Breaking Bad Habits with GitLab CI
Breaking Bad Habits with GitLab CIBreaking Bad Habits with GitLab CI
Breaking Bad Habits with GitLab CI
 
A painless self-hosted Git service: Gitea
A painless self-hosted Git service: GiteaA painless self-hosted Git service: Gitea
A painless self-hosted Git service: Gitea
 
Jenkins to Gitlab - Intelligent Build-Pipelines
Jenkins to Gitlab - Intelligent Build-PipelinesJenkins to Gitlab - Intelligent Build-Pipelines
Jenkins to Gitlab - Intelligent Build-Pipelines
 
Git introduction for Beginners
Git introduction for BeginnersGit introduction for Beginners
Git introduction for Beginners
 

Destacado

Introduction to Kaizen by Toby Hunt
Introduction to Kaizen by Toby HuntIntroduction to Kaizen by Toby Hunt
Introduction to Kaizen by Toby Huntpebble {code}
 
Accomplishments-Certifications
Accomplishments-CertificationsAccomplishments-Certifications
Accomplishments-CertificationsMelissa Schaefer
 
Potocnik et al - Efekti i optimizacija rada višefunkcionalne mašine u slučaju...
Potocnik et al - Efekti i optimizacija rada višefunkcionalne mašine u slučaju...Potocnik et al - Efekti i optimizacija rada višefunkcionalne mašine u slučaju...
Potocnik et al - Efekti i optimizacija rada višefunkcionalne mašine u slučaju...Dusan Stojnic
 
More Leadership Lessons Workshop Global
More Leadership Lessons Workshop GlobalMore Leadership Lessons Workshop Global
More Leadership Lessons Workshop GlobalJohn Fall
 
Ch 1- Water and Soil, Stone and Metal
Ch 1- Water and Soil, Stone and MetalCh 1- Water and Soil, Stone and Metal
Ch 1- Water and Soil, Stone and MetalCraig Campbell
 
Landskapsreformen i Österbotten - Maakuntauudistus Pohjanmaalla
Landskapsreformen i Österbotten - Maakuntauudistus PohjanmaallaLandskapsreformen i Österbotten - Maakuntauudistus Pohjanmaalla
Landskapsreformen i Österbotten - Maakuntauudistus PohjanmaallaMikaela Jussila
 
Choose Coach Hire Adelaide or Adelaide Coach Hire Services
Choose Coach Hire Adelaide or Adelaide Coach Hire ServicesChoose Coach Hire Adelaide or Adelaide Coach Hire Services
Choose Coach Hire Adelaide or Adelaide Coach Hire ServicesCorstton Coaches
 
PivotReseller_Sales_Profit_by_Country_and_Occupation
PivotReseller_Sales_Profit_by_Country_and_OccupationPivotReseller_Sales_Profit_by_Country_and_Occupation
PivotReseller_Sales_Profit_by_Country_and_OccupationMike Santeramo
 
Huuhedin suvilahgui 1
Huuhedin suvilahgui 1Huuhedin suvilahgui 1
Huuhedin suvilahgui 1oyunubuns
 
Safety Leadership Event 2016 - Leader del miglioramento virale
Safety Leadership Event 2016 - Leader del miglioramento viraleSafety Leadership Event 2016 - Leader del miglioramento virale
Safety Leadership Event 2016 - Leader del miglioramento viraleSebastiano Trapani
 
Comparatividad Entre Piscis Y Acuarius
Comparatividad Entre  Piscis Y  AcuariusComparatividad Entre  Piscis Y  Acuarius
Comparatividad Entre Piscis Y Acuariusguest6942b5
 
Rezultate Eco-Scoala
Rezultate Eco-ScoalaRezultate Eco-Scoala
Rezultate Eco-ScoalaProfesorgeo
 

Destacado (17)

Introduction to Kaizen by Toby Hunt
Introduction to Kaizen by Toby HuntIntroduction to Kaizen by Toby Hunt
Introduction to Kaizen by Toby Hunt
 
Accomplishments-Certifications
Accomplishments-CertificationsAccomplishments-Certifications
Accomplishments-Certifications
 
Boquita deluna
Boquita delunaBoquita deluna
Boquita deluna
 
Potocnik et al - Efekti i optimizacija rada višefunkcionalne mašine u slučaju...
Potocnik et al - Efekti i optimizacija rada višefunkcionalne mašine u slučaju...Potocnik et al - Efekti i optimizacija rada višefunkcionalne mašine u slučaju...
Potocnik et al - Efekti i optimizacija rada višefunkcionalne mašine u slučaju...
 
The euro
The euroThe euro
The euro
 
More Leadership Lessons Workshop Global
More Leadership Lessons Workshop GlobalMore Leadership Lessons Workshop Global
More Leadership Lessons Workshop Global
 
HEAT TRANSFER
HEAT TRANSFERHEAT TRANSFER
HEAT TRANSFER
 
Ch 1- Water and Soil, Stone and Metal
Ch 1- Water and Soil, Stone and MetalCh 1- Water and Soil, Stone and Metal
Ch 1- Water and Soil, Stone and Metal
 
Landskapsreformen i Österbotten - Maakuntauudistus Pohjanmaalla
Landskapsreformen i Österbotten - Maakuntauudistus PohjanmaallaLandskapsreformen i Österbotten - Maakuntauudistus Pohjanmaalla
Landskapsreformen i Österbotten - Maakuntauudistus Pohjanmaalla
 
Choose Coach Hire Adelaide or Adelaide Coach Hire Services
Choose Coach Hire Adelaide or Adelaide Coach Hire ServicesChoose Coach Hire Adelaide or Adelaide Coach Hire Services
Choose Coach Hire Adelaide or Adelaide Coach Hire Services
 
Patientencommunicatie
PatientencommunicatiePatientencommunicatie
Patientencommunicatie
 
PivotReseller_Sales_Profit_by_Country_and_Occupation
PivotReseller_Sales_Profit_by_Country_and_OccupationPivotReseller_Sales_Profit_by_Country_and_Occupation
PivotReseller_Sales_Profit_by_Country_and_Occupation
 
Huuhedin suvilahgui 1
Huuhedin suvilahgui 1Huuhedin suvilahgui 1
Huuhedin suvilahgui 1
 
Unit 2
Unit 2Unit 2
Unit 2
 
Safety Leadership Event 2016 - Leader del miglioramento virale
Safety Leadership Event 2016 - Leader del miglioramento viraleSafety Leadership Event 2016 - Leader del miglioramento virale
Safety Leadership Event 2016 - Leader del miglioramento virale
 
Comparatividad Entre Piscis Y Acuarius
Comparatividad Entre  Piscis Y  AcuariusComparatividad Entre  Piscis Y  Acuarius
Comparatividad Entre Piscis Y Acuarius
 
Rezultate Eco-Scoala
Rezultate Eco-ScoalaRezultate Eco-Scoala
Rezultate Eco-Scoala
 

Similar a Deploy code easily with Git hooks

Getting started with git
Getting started with gitGetting started with git
Getting started with gitPawan Kumar.v
 
How To Install GitLab As Your Private GitHub Clone
How To Install GitLab As Your Private GitHub CloneHow To Install GitLab As Your Private GitHub Clone
How To Install GitLab As Your Private GitHub CloneVEXXHOST Private Cloud
 
Git: Why And How to
Git: Why And How toGit: Why And How to
Git: Why And How tolanhuonga3
 
Introduction to git and Github
Introduction to git and GithubIntroduction to git and Github
Introduction to git and GithubWycliff1
 
Advanced Git Tutorial
Advanced Git TutorialAdvanced Git Tutorial
Advanced Git TutorialSage Sharp
 
.Git for WordPress Developers
.Git for WordPress Developers.Git for WordPress Developers
.Git for WordPress Developersmpvanwinkle
 
GIT workshop at Selenium Conference 2018
GIT workshop at Selenium Conference 2018GIT workshop at Selenium Conference 2018
GIT workshop at Selenium Conference 2018Pooja Shah
 
GIT_GITHUB_2016_06_17
GIT_GITHUB_2016_06_17GIT_GITHUB_2016_06_17
GIT_GITHUB_2016_06_17siva ram
 
Git installation and configuration
Git installation and configurationGit installation and configuration
Git installation and configurationKishor Kumar
 
Github - Git Training Slides: Foundations
Github - Git Training Slides: FoundationsGithub - Git Training Slides: Foundations
Github - Git Training Slides: FoundationsLee Hanxue
 
You're doing it wrong! Git it right!
You're doing it wrong! Git it right!You're doing it wrong! Git it right!
You're doing it wrong! Git it right!Cory Webb
 

Similar a Deploy code easily with Git hooks (20)

Getting started with git
Getting started with gitGetting started with git
Getting started with git
 
Github basics
Github basicsGithub basics
Github basics
 
3 Git
3 Git3 Git
3 Git
 
How To Install GitLab As Your Private GitHub Clone
How To Install GitLab As Your Private GitHub CloneHow To Install GitLab As Your Private GitHub Clone
How To Install GitLab As Your Private GitHub Clone
 
Git: Why And How to
Git: Why And How toGit: Why And How to
Git: Why And How to
 
Introduction to git and Github
Introduction to git and GithubIntroduction to git and Github
Introduction to git and Github
 
Git & github
Git & githubGit & github
Git & github
 
Git Basics
Git BasicsGit Basics
Git Basics
 
Advanced Git Tutorial
Advanced Git TutorialAdvanced Git Tutorial
Advanced Git Tutorial
 
.Git for WordPress Developers
.Git for WordPress Developers.Git for WordPress Developers
.Git for WordPress Developers
 
GIT workshop at Selenium Conference 2018
GIT workshop at Selenium Conference 2018GIT workshop at Selenium Conference 2018
GIT workshop at Selenium Conference 2018
 
Git 1
Git 1Git 1
Git 1
 
GIT_GITHUB_2016_06_17
GIT_GITHUB_2016_06_17GIT_GITHUB_2016_06_17
GIT_GITHUB_2016_06_17
 
Git basics
Git basicsGit basics
Git basics
 
Git installation and configuration
Git installation and configurationGit installation and configuration
Git installation and configuration
 
Wokshop de Git
Wokshop de Git Wokshop de Git
Wokshop de Git
 
Github - Git Training Slides: Foundations
Github - Git Training Slides: FoundationsGithub - Git Training Slides: Foundations
Github - Git Training Slides: Foundations
 
Git basics
Git basicsGit basics
Git basics
 
GitHub Event.pptx
GitHub Event.pptxGitHub Event.pptx
GitHub Event.pptx
 
You're doing it wrong! Git it right!
You're doing it wrong! Git it right!You're doing it wrong! Git it right!
You're doing it wrong! Git it right!
 

Último

How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.Curtis Poe
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsSergiu Bodiu
 
Potential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and InsightsPotential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and InsightsRavi Sanghani
 
2024 April Patch Tuesday
2024 April Patch Tuesday2024 April Patch Tuesday
2024 April Patch TuesdayIvanti
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsPixlogix Infotech
 
Data governance with Unity Catalog Presentation
Data governance with Unity Catalog PresentationData governance with Unity Catalog Presentation
Data governance with Unity Catalog PresentationKnoldus Inc.
 
Manual 508 Accessibility Compliance Audit
Manual 508 Accessibility Compliance AuditManual 508 Accessibility Compliance Audit
Manual 508 Accessibility Compliance AuditSkynet Technologies
 
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxLoriGlavin3
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteDianaGray10
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024Lonnie McRorey
 
Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...Rick Flair
 
UiPath Community: Communication Mining from Zero to Hero
UiPath Community: Communication Mining from Zero to HeroUiPath Community: Communication Mining from Zero to Hero
UiPath Community: Communication Mining from Zero to HeroUiPathCommunity
 
Generative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersGenerative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersRaghuram Pandurangan
 
What is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfWhat is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfMounikaPolabathina
 
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24Mark Goldstein
 
(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...
(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...
(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...AliaaTarek5
 
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...panagenda
 
Assure Ecommerce and Retail Operations Uptime with ThousandEyes
Assure Ecommerce and Retail Operations Uptime with ThousandEyesAssure Ecommerce and Retail Operations Uptime with ThousandEyes
Assure Ecommerce and Retail Operations Uptime with ThousandEyesThousandEyes
 
The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxLoriGlavin3
 

Último (20)

How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platforms
 
Potential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and InsightsPotential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and Insights
 
2024 April Patch Tuesday
2024 April Patch Tuesday2024 April Patch Tuesday
2024 April Patch Tuesday
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and Cons
 
Data governance with Unity Catalog Presentation
Data governance with Unity Catalog PresentationData governance with Unity Catalog Presentation
Data governance with Unity Catalog Presentation
 
Manual 508 Accessibility Compliance Audit
Manual 508 Accessibility Compliance AuditManual 508 Accessibility Compliance Audit
Manual 508 Accessibility Compliance Audit
 
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test Suite
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024
 
Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...
 
UiPath Community: Communication Mining from Zero to Hero
UiPath Community: Communication Mining from Zero to HeroUiPath Community: Communication Mining from Zero to Hero
UiPath Community: Communication Mining from Zero to Hero
 
Generative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersGenerative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information Developers
 
What is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfWhat is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdf
 
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
 
(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...
(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...
(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...
 
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...
 
Assure Ecommerce and Retail Operations Uptime with ThousandEyes
Assure Ecommerce and Retail Operations Uptime with ThousandEyesAssure Ecommerce and Retail Operations Uptime with ThousandEyes
Assure Ecommerce and Retail Operations Uptime with ThousandEyes
 
The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptx
 

Deploy code easily with Git hooks

  • 2. Igor Santos Web developer ● From Rio de Janeiro, Brazil ● PHP Developer for ~6 years ● Ruby and JS Developer for fun ● Playing around with git for ~2 years slideshare.net/igorsantos07
  • 3. 0. Introduction ● Knows what Git is? ● Have ever used Git in the command line? ● Have ever deployed code? ○ How? SCP? WGet? ● Anyone developing in the production server?
  • 4. 1. Git Basics ● Commit: Saves changes with a description ● Pull: Get commits from a server ● Push: Send commits to a server ● Remotes ○ A remote machine that has a copy of the repository and accepts your commits ○ In a common centralized organization you usually have one, but it's possible to have many ○ Example: main repo is BitBucket or Google Code, mirrored to GitHub
  • 5. 2. Configure your server igor@local$ ssh santos@bluenose.cs.dal.ca password: ********** santos@bluenose$ mkdir repos santos@bluenose$ cd repos santos@bluenose$ pwd /users/cs/santos/repos santos@bluenose$ git clone «repo» myRep --bare This creates a clone of that repository that works just as another repository: with all administrative data, but not useable for development, as the code is not really checked in - just the Git meta-data. Take note
  • 6. igor@local$ cd dev/myCode igor@local$ git remote add prod ssh://santos@bluenose.cs.dal.ca:/users/cs/santos/repos/myRep igor@local$ "Hi there!" > README.mkd igor@local$ git commit "+ Adding readme" igor@local$ git push prod 2. Configure your server Name given to the remote server Complete repository URL No line break!
  • 7. igor@local$ git commit "+ Adding readme" igor@local$ git push prod Q: OK, so... where's my README file? A: In the repository! Q: I can't see it. «not really a question» 2. Configure your server
  • 8. 3. Git Hooks ● 2 types: client and server hooks ● Client: ○ pre/post-commit ○ [prepare-]commit-msg ○ post-checkout, post-merge ● Server: ○ pre/post-receive Once per push ○ update Once per pushed branch http://git-scm.com/book/en/Customizing-Git-Git-Hooks
  • 9. 3. Git Hooks Simple copy $ cat hooks/post-receive #!/bin/sh GIT_WORK_TREE=/var/www/mysite git checkout -f Opposite of git clone --bare: copies the entire repository code, without git data. By default does that with the master branch, but you can use other options here as well. GIT_WORK_TREE tells git where it would copy stuff.
  • 10. 3. Git Hooks Complete deployment script https://bitbucket.org/igorsantos07/calen-do/src/3fea92ee46c1/git-hooks/update
  • 11. 4. Advanced ideas GitHub and other Git online repositories have options to do HTTP requests with code information after pushes, similar to post- receive hooks. This data can be used to trigger a deployment script in the server. There's also an online service called DeployHQ, where you can configure any repository (SVN/Git/Hg) and many deploy methods (FTP/SFTP/S3/Rackspace). It deploys new code using the chosen method.