Last active
January 1, 2016 21:09
-
-
Save necolas/8201662 to your computer and use it in GitHub Desktop.
Revisions
-
necolas revised this gist
Jan 2, 2014 . 2 changed files with 43 additions and 94 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,62 +1 @@ See: [A simple Git deployment strategt for static sites](http://nicolasgallagher.com/simple-git-deployment-strategy-for-static-sites/) This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,34 +1,44 @@ BUILD_DIR := ./build STAGING_REPO = ssh://user@hostname/~/staging.example.git PROD_REPO = ssh://user@hostname/~/example.git install: npm install # Deploy tasks staging: build git-staging deploy @ git tag -f staging @ echo "Staging deploy complete" prod: build git-prod deploy @ git tag -f production @ echo "Production deploy complete" # Build tasks build: clean # whatever your build step is # Sub-tasks tasks clean: @ rm -rf $(BUILD_DIR) git-prod: @ cd $(BUILD_DIR) && \ git init && \ git remote add origin $(PROD_REPO) git-staging: @ cd $(BUILD_DIR) && \ git init && \ git remote add origin $(STAGING_REPO) deploy: @ cd $(BUILD_DIR) && \ git add -A && \ git commit -m "Release" && \ git push -f origin +master:refs/heads/master .PHONY: install build clean deploy git-prod git-staging prod staging -
necolas revised this gist
Dec 31, 2013 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -8,7 +8,7 @@ I wanted something simple for staging and deploying my static site. ## Remote server config ssh into your server (has your public ssh key) ``` ssh you@example.org -
necolas revised this gist
Dec 31, 2013 . 1 changed file with 3 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -29,4 +29,6 @@ deploy: prod: build clone-prod deploy staging: build clone-staging deploy .PHONY: build clean-deploy clone-prod clone-staging deploy prod staging -
necolas revised this gist
Dec 31, 2013 . 1 changed file with 35 additions and 14 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,4 +1,4 @@ # Ghetto git deployment strategy I wanted something simple for staging and deploying my static site. @@ -8,34 +8,55 @@ I wanted something simple for staging and deploying my static site. ## Remote server config ssh into your server ``` ssh you@example.org ``` create a directory for your site ``` mkdir ~/example.com ``` create a directory for git ``` mkdir ~/example.git ``` create a bare git repo ``` cd example.git git init --bare ``` setup a post-receive hook ``` cat > hooks/post-receive #!/bin/sh GIT_WORK_TREE=/path/to/example.com git checkout -f chmod +x hooks/post-receive ``` Repeat for staging server, if you want. ## Local process I'm using Make: Deploy to production ``` make prod ``` Deploy to staging ``` make staging ``` -
necolas revised this gist
Dec 31, 2013 . 2 changed files with 13 additions and 5 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -10,7 +10,7 @@ I wanted something simple for staging and deploying my static site. Repeat for staging server, if you want. ``` # ssh into your server $ ssh you@example.org @@ -37,4 +37,5 @@ I'm using Make: ``` make prod make staging ``` This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -6,11 +6,16 @@ STAGING_REPO = ssh://you@example.org/~/staging.example.git PROD_REPO = ssh://you@example.org/~/example.git build: # whatever your build step is clean-deploy: @ rm -rf $(DEPLOY_DIR) clone-prod: clean-deploy git clone $(PROD_REPO) $(DEPLOY_DIR) clone-staging: clean-deploy git clone $(STAGING_REPO) $(DEPLOY_DIR) # force update the remote repo with whatever is in the build directory deploy: @@ -22,4 +27,6 @@ deploy: git branch -M master && \ git push -f origin +master:refs/heads/master prod: build clone-prod deploy staging: build clone-staging deploy -
necolas created this gist
Dec 31, 2013 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,40 @@ # Simple git deployment strategy I wanted something simple for staging and deploying my static site. 1. Generate build locally 2. Push the build to a bare git repo on your server 3. A `post-receive` hook checks out the files in the public directory ## Remote server config Repeat for staging server, if you want. ```console # ssh into your server $ ssh you@example.org # create a directory for your site $ mkdir ~/example.com # create a directory for git $ mkdir ~/example.git # create a bare git repo $ cd example.git $ git init --bare # setup a post-receive hook $ cat > hooks/post-receive #!/bin/sh GIT_WORK_TREE=/path/to/example.com git checkout -f $ chmod +x hooks/post-receive ``` ## Local process I'm using Make: ``` make prod ``` This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,25 @@ # Local project makefile BUILD_DIR := ./build DEPLOY_DIR := ./deploy STAGING_REPO = ssh://you@example.org/~/staging.example.git PROD_REPO = ssh://you@example.org/~/example.git build: # whatever your build step is clone-staging: @ rm -rf $(DEPLOY_DIR) && \ git clone $(STAGING_REPO) $(DEPLOY_DIR) # force update the remote repo with whatever is in the build directory deploy: cp -R $(BUILD_DIR)/ $(DEPLOY_DIR) && \ cd $(DEPLOY_DIR) && \ git checkout --orphan new_master && \ git add -A && \ git commit -m "Release" && \ git branch -M master && \ git push -f origin +master:refs/heads/master staging: build clone-staging deploy