Dan Kanze
Dan Kanze

Reputation: 18595

using shell script to automate git commits and ssh apache server deployments?

I'm trying to figure out how I go about automating this process using a script.

I don't know what I'd use, or how to go about it. I'm looking to get pointed in the right direction.

In git :

git commit -am "my commit"
git pull origin my_branch
git push origin my_branch
git archive --format zip --output /c/git/(environment)_(date)_(commithash).zip my_branch
scp (environment)_(date)_(hash).zip [email protected]:/var/www/html-(domain)
password123

In apache : ( usually i putty in... )

root
password123
cd /var/www/html-(domain)/(environment)
unzip ../(environment)_(date)_(commithash).zip
n
n
A
cd ..
cp -pr (environment) (environment)_(date)_(commithash)
exit

To explain whats going on, I am pushing my latest commit, SCPing to apache server docroot, deploying, and making backup with commit hash.

Upvotes: 0

Views: 852

Answers (2)

willoller
willoller

Reputation: 7330

You are taking the first step toward Continuous Integration.

I use Jenkins which I set up to do:

  • git pull origin master
  • run unit tests
  • deploy code
  • run db deployments
  • update ticket system with success/fail

There are lots of extensions and tools as well, works with any language, etc.

Upvotes: 1

supervacuo
supervacuo

Reputation: 9242

You can either use a shell script as you plan to -- just save the commands you want to run (one per line) in a file, add #!/bin/bash at the top, make it executable with chmod +x myscript.sh (the .sh file extension is not required) and then run it with ./myscript.sh.

You may find it easier to use scaffolding that specifically assists with deployment. A nice-looking one of these systems (that I have yet to try) that uses shell scripts is deliver.

Upvotes: 1

Related Questions