Forked from thomasfr/Git push deployment in 7 easy steps.md
Created
April 9, 2018 09:35
-
-
Save schmaluk/0c4b11d19430ad1f1a8247d0f5b8349d to your computer and use it in GitHub Desktop.
Revisions
-
Thomas Fritz revised this gist
Apr 11, 2017 . 1 changed file with 5 additions and 0 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 @@ -66,6 +66,11 @@ do export DEPLOY_NEWREV="$newrev" export DEPLOY_REFNAME="$refname" if [ "$DEPLOY_NEWREV" = "0000000000000000000000000000000000000000" ]; then echo "githook: This ref has been deleted" exit 1 fi if [ ! -z "${DEPLOY_ALLOWED_BRANCH}" ]; then if [ "${DEPLOY_ALLOWED_BRANCH}" != "$DEPLOY_BRANCH" ]; then echo "githook: Branch '$DEPLOY_BRANCH' of '${DEPLOY_APP_NAME}' application will not be deployed. Exiting." -
Thomas Fritz revised this gist
Apr 11, 2017 . 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 @@ -5,7 +5,7 @@ # # The MIT License (MIT) # # Copyright (c) 2014-2017 FRITZ Thomas # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal -
Thomas Fritz revised this gist
Jun 8, 2015 . 1 changed file with 46 additions and 42 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 @@ -5,7 +5,7 @@ # # The MIT License (MIT) # # Copyright (c) 2014-2015 FRITZ Thomas # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal @@ -27,68 +27,72 @@ # # Application Name: export DEPLOY_APP_NAME=`whoami` # This is the root deploy dir. export DEPLOY_ROOT="${HOME}/work" # When receiving a new git push, the received branch gets compared to this one. # If you do not need this, just add a comment export DEPLOY_ALLOWED_BRANCH="master" # You could use this to do a backup before updating to be able to do a quick rollback. # If you need this just delete the comment and modify to your needs #PRE_UPDATE_CMD='cd ${DEPLOY_ROOT} && backup.sh' # Use this to do update tasks and maybe service restarts # If you need this just delete the comment and modify to your needs #POST_UPDATE_CMD='cd ${DEPLOY_ROOT} && make update' ########################################################################################### export GIT_DIR="$(cd $(dirname $(dirname $0));pwd)" export GIT_WORK_TREE="${DEPLOY_ROOT}" IP="$(ip addr show eth0 | grep 'inet ' | cut -f2 | awk '{ print $2}')" echo "githook: $(date): Welcome to '$(hostname -f)' (${IP})" echo # Make sure directory exists. Maybe its deployed for the first time. mkdir -p "${DEPLOY_ROOT}" # Loop, because it is possible to push more than one branch at a time. (git push --all) while read oldrev newrev refname do export DEPLOY_BRANCH=$(git rev-parse --symbolic --abbrev-ref $refname) export DEPLOY_OLDREV="$oldrev" export DEPLOY_NEWREV="$newrev" export DEPLOY_REFNAME="$refname" if [ ! -z "${DEPLOY_ALLOWED_BRANCH}" ]; then if [ "${DEPLOY_ALLOWED_BRANCH}" != "$DEPLOY_BRANCH" ]; then echo "githook: Branch '$DEPLOY_BRANCH' of '${DEPLOY_APP_NAME}' application will not be deployed. Exiting." exit 1 fi fi if [ ! -z "${PRE_UPDATE_CMD}" ]; then echo echo "githook: PRE UPDATE (CMD: '${PRE_UPDATE_CMD}'):" eval $PRE_UPDATE_CMD || exit 1 fi # Make sure GIT_DIR and GIT_WORK_TREE is correctly set and 'export'ed. Otherwhise # these two environment variables could also be passed as parameters to the git cli echo "githook: I will deploy '${DEPLOY_BRANCH}' branch of the '${DEPLOY_APP_NAME}' project to '${DEPLOY_ROOT}'" git checkout -f "${DEPLOY_BRANCH}" || exit 1 git reset --hard "$DEPLOY_NEWREV" || exit 1 if [ ! -z "${POST_UPDATE_CMD}" ]; then echo echo "githook: POST UPDATE (CMD: '${POST_UPDATE_CMD}'):" eval $POST_UPDATE_CMD || exit 1 fi done echo echo "githook: $(date): See you soon at '$(hostname -f)' (${IP})" exit 0 -
Thomas Fritz revised this gist
Jul 28, 2014 . 1 changed file with 2 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 @@ -68,7 +68,8 @@ do # Make sure GIT_DIR and GIT_WORK_TREE is correctly set and 'export'ed. Otherwhise # these two environment variables could also be passed as parameters to the git cli echo "githook: I will deploy '${DEPLOY_BRANCH}' branch of the '${PROJECT_NAME}' project to '${DEPLOY_TO}'" git checkout -f "${DEPLOY_BRANCH}" git reset --hard HEAD if [ ! -z "${UPDATE_CMD}" ]; then echo -
Thomas Fritz revised this gist
Mar 22, 2014 . 1 changed file with 1 addition and 0 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 @@ -112,6 +112,7 @@ Here are some more configuration files as a starting point: * [NGINX reverse proxy to local service running on non-privileged port (e.g. node.js)](https://gist.github.com/thomasfr/8653547) * [A common set of iptable rules](https://gist.github.com/thomasfr/9712418) * [A systemd service file for autossh (keeps an ssh tunnel open)](https://gist.github.com/thomasfr/9707568) * [Warmly - a poor mans wget based cache warmer script](https://gist.github.com/thomasfr/7926314) -
Thomas Fritz revised this gist
Mar 22, 2014 . 1 changed file with 2 additions and 2 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 @@ -109,9 +109,9 @@ make deploy *Congratulations, you just setup git push deployment with automated build and service restart* Here are some more configuration files as a starting point: * [NGINX reverse proxy to local service running on non-privileged port (e.g. node.js)](https://gist.github.com/thomasfr/8653547) * [A common set of iptable rules](https://gist.github.com/thomasfr/9712418) * [A systemd service file for autossh (keeps an ssh tunnel open)](https://gist.github.com/thomasfr/9707568) -
Thomas Fritz revised this gist
Mar 22, 2014 . 1 changed file with 11 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 @@ -5,6 +5,7 @@ This is how i used it on a *Debian Wheezy testing* (https://www.debian.org/relea Discuss, ask questions, etc. here https://news.ycombinator.com/item?id=7445545 ## On the server (example.com) 1. Create a user on `example.com`, as which we (the git client) connect (push) to `exmaple.com`. @@ -101,7 +102,16 @@ Discuss, ask questions, etc. here https://news.ycombinator.com/item?id=7445545 ``` * Repeat: Develop, test, commit and push :) ```bash make deploy ``` *Congratulations, you just setup git push deployment with automated build and service restart* Here are some more configuration files as a starting point: * [NGINX Reverse Proxy for local service running on non-privileged port (e.g. node.js)](https://gist.github.com/thomasfr/8653547) * [A common set of iptable rules](https://gist.github.com/thomasfr/9712418) * [A systemd service file for autossh](https://gist.github.com/thomasfr/9707568) -
Thomas Fritz revised this gist
Mar 22, 2014 . 1 changed file with 1 addition and 0 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,5 +1,6 @@ # How-to setup a simple git push deployment These are my notes basically. At first i created this gist just as a reminder for myself. But feel free to use this for your project as a starting point. If you have questions you can find me on twitter @thomasf https://twitter.com/thomasf This is how i used it on a *Debian Wheezy testing* (https://www.debian.org/releases/testing/) Discuss, ask questions, etc. here https://news.ycombinator.com/item?id=7445545 -
Thomas Fritz revised this gist
Mar 22, 2014 . 1 changed file with 2 additions and 0 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,6 +1,8 @@ # How-to setup a simple git push deployment These are my notes basically. At first i created this gist just as a reminder for myself. But feel free to use this for your project as a starting point. If you have questions you can find me on twitter @thomasf https://twitter.com/thomasf Discuss, ask questions, etc. here https://news.ycombinator.com/item?id=7445545 ## On the server (example.com) -
Thomas Fritz revised this gist
Mar 22, 2014 . 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 @@ -1,5 +1,5 @@ # How-to setup a simple git push deployment These are my notes basically. At first i created this gist just as a reminder for myself. But feel free to use this for your project as a starting point. If you have questions you can find me on twitter @thomasf https://twitter.com/thomasf ## On the server (example.com) -
Thomas Fritz revised this gist
Mar 22, 2014 . 1 changed file with 4 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 @@ -33,6 +33,8 @@ These are my notes basically. At first i created this gist just as a reminder fo ```bash vim testapp/hooks/post-receive ## Paste the post-receive script from this gist and save ## If you do not need to execute a 'build' and/or 'restart' command, ## just delete or comment the lines 'UPDATE_CMD' and 'RESTART_CMD' chmod +x testapp/hooks/post-receive ``` @@ -43,7 +45,8 @@ These are my notes basically. At first i created this gist just as a reminder fo ``` * (Optional) Add a systemd service file for your app. If you are using `systemd`, you can use the `testapp.service` file from this gist. Make sure you name it like your repository. The post-receive hook can automatically restart your app. You will also have to allow user git to make the `sudo` call. Be very careful and restrictive with this! ## On the client -
Thomas Fritz revised this gist
Mar 22, 2014 . 1 changed file with 12 additions and 9 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 @@ -5,30 +5,34 @@ These are my notes basically. At first i created this gist just as a reminder fo ## On the server (example.com) 1. Create a user on `example.com`, as which we (the git client) connect (push) to `exmaple.com`. We set `git-shell` as the login shell, so it is not possible to interactively login as this user. ```bash sudo useradd -m -s /usr/bin/git-shell git ``` 2. Add your ssh public key to the `authorized_keys` file of the created user: ```bash ## Because user git can not interactively login, we have to use sudo to get git temporarily sudo -u git bash cd ~ ## cd /home/git mkdir -p .ssh vim .ssh/authorized_keys ## Paste your public key and save ``` 3. Create a `git bare` repo for your project: ```bash mkdir testapp cd testapp ## /home/git/testapp git init --bare ``` 4. Copy the `post-receive` script from this gist to the `hooks` dir of the created bare repo. ```bash vim testapp/hooks/post-receive ## Paste the post-receive script from this gist and save chmod +x testapp/hooks/post-receive ``` @@ -38,24 +42,24 @@ These are my notes basically. At first i created this gist just as a reminder fo sudo chmod 775 /var/www ``` * (Optional) Add a systemd service file for your app. If you are using `systemd`, you can use the `testapp.service` file from this gist. Make sure you name it like your repository. The post-receive hook can automatically restart your app. ## On the client 6. Create a git repo and add our newly created `remote`: ```bash mkdir testapp cd testapp git init git remote add production [email protected]:~/testapp ``` 7. Commit and push to production: ``` $ vim Makefile ## Paste contents of Makefile from this gist (as an example) $ git add . $ git commit -am "test commit" $ git push production master @@ -88,10 +92,9 @@ These are my notes basically. At first i created this gist just as a reminder fo To [email protected]:~/testapp 08babc4..95cabcc master -> master ``` * Repeat: Develop, test, commit and push :) Congratulations, you just setup git push deployment with automated build and service restart -
Thomas Fritz revised this gist
Mar 22, 2014 . 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 @@ -1,5 +1,5 @@ # How-to setup a simple git push deployment These are my notes basically. At first i created this gist just as a reminder for myself. But feel free to use this for your project as a starting point. If you have questions you can find me on twitter @thomasf ## On the server (example.com) -
Thomas Fritz revised this gist
Mar 22, 2014 . 1 changed file with 2 additions and 2 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,10 +1,10 @@ # How-to setup a simple git push deployment These are my notes basically. I first created this just as a reminder for myself. But feel free to use this for your project as a starting point. If you have questions you can find me on twitter @thomasf ## On the server (example.com) 1. Create a user on `example.com`, as which we (the git client) connect (push) to `exmaple.com`. ```bash sudo useradd -m -s /usr/bin/git-shell git ``` -
Thomas Fritz revised this gist
Mar 21, 2014 . 1 changed file with 3 additions and 3 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 @@ -28,7 +28,7 @@ These are my notes basically. I first created this just as a reminder for myself 4. Copy the `post-receive` script from this gist to the `hooks` dir of the created bare repo. ```bash vim testapp/hooks/post-receive # Paste the contents of post-receive from this gist chmod +x testapp/hooks/post-receive ``` @@ -38,8 +38,8 @@ These are my notes basically. I first created this just as a reminder for myself sudo chmod 775 /var/www ``` 6. (Optional) Add a systemd service file for your app. If you are using `systemd`, you can use the `testapp.service` file from this gist. Make sure you name it like your repository, so the post-receive hook can automatically find and restart your app. ## On the client -
Thomas Fritz revised this gist
Mar 21, 2014 . 1 changed file with 2 additions and 3 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 @@ -4,10 +4,9 @@ These are my notes basically. I first created this just as a reminder for myself ## On the server (example.com) 1. Create a user on `example.com`, as which we (the git client) connects (push) to `exmaple.com`. ```bash sudo useradd -m -s /usr/bin/git-shell git ``` 2. Add your ssh public key to the `authorized_keys` file of the created user: -
Thomas Fritz revised this gist
Mar 21, 2014 . 1 changed file with 6 additions and 4 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,5 +1,8 @@ # How-to setup a simple git push deployment These are my notes basically. I first created this just as a reminder for myself. Feel free to use this for your project as a starting point. ## On the server (example.com) 1. Create a user on `example.com`, as which we (the git client) connects (push) to `exmaple.com`. (I am using gid und uid higher than normally because, in case i want to restrict the user later based on the uid, i could then check for uid>10000 or gid>10000 - but you can safely ommit the `-u` and `-g` flags) ```bash @@ -40,8 +43,7 @@ On the server (example.com) If you are using `systemd`, you can use `testapp.service` from this gist. Make sure you name it like your repository, so the post-receive hook can automatically find and restart your app. ## On the client 7. Create a git repo and add our newly created `remote`: ```bash -
Thomas Fritz renamed this gist
Mar 21, 2014 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
Thomas Fritz renamed this gist
Mar 21, 2014 . 1 changed file with 8 additions and 4 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 @@ -36,21 +36,25 @@ On the server (example.com) sudo chmod 775 /var/www ``` 6. (Optional) Systemd service file for your app If you are using `systemd`, you can use `testapp.service` from this gist. Make sure you name it like your repository, so the post-receive hook can automatically find and restart your app. On the client ============= 7. Create a git repo and add our newly created `remote`: ```bash mkdir testapp cd testapp git init git remote add production [email protected]:~/testapp ``` 8. Commit and push to production: ``` $ vim Makefile $ # Paste contents of Makefile from this gist (as an example) $ git add . $ git commit -am "test commit" $ git push production master @@ -86,7 +90,7 @@ On the client $ ``` 9. Repeat: Develop, commit and push :) Congratulations, you just setup git push deployment with automated build and service restart -
Thomas Fritz renamed this gist
Mar 21, 2014 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
Thomas Fritz revised this gist
Mar 21, 2014 . 1 changed file with 2 additions and 0 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 @@ -86,6 +86,8 @@ On the client $ ``` 8. Repeat: Develop, commit and push :) Congratulations, you just setup git push deployment with automated build and service restart -
Thomas Fritz revised this gist
Mar 21, 2014 . 1 changed file with 23 additions and 0 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 @@ -0,0 +1,23 @@ [Unit] Description=node.js testapp Requires=network.target After=network.target [Service] WorkingDirectory=/var/www/testapp Type=forking ExecStart=/bin/bash -c 'sleep 3;echo "I am starting";echo "$(whoami)";' # For a node.js app this could be something like: #ExecStart=/bin/bash -c 'npm start' StandardOutput=syslog StandardError=syslog SyslogIdentifier=testapp User=www-data Group=www-data Environment="NODE_ENV=production" "DEBUG=testapp:*" [Install] WantedBy=multi-user.target -
Thomas Fritz revised this gist
Mar 21, 2014 . 2 changed files with 36 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 @@ -7,4 +7,5 @@ deploy: update: @echo "Makefile: Doing UPDATE stuff like grunt, gulp, rake,..." @whoami @pwd 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 @@ -50,10 +50,40 @@ On the client 7. Commit and push to production: ``` $ echo "foo" >> test $ git add . $ git commit -am "test commit" $ git push production master Counting objects: 12, done. Delta compression using up to 4 threads. Compressing objects: 100% (4/4), done. Writing objects: 100% (4/4), 432 bytes | 0 bytes/s, done. Total 4 (delta 2), reused 0 (delta 0) remote: +++++++++++++++++++++++ Welcome to 'example.com' (1.2.3.4) ++++++++++++++++++++++++ remote: remote: githook: I will deploy 'master' branch of the 'testapp' project to '/var/www/testapp' remote: remote: githook: UPDATE (CMD: 'cd "${DEPLOY_TO}" && make "update"'): remote: Makefile: Doing UPDATE stuff like grunt, gulp, rake,... remote: git remote: /var/www/testapp remote: remote: githook: RESTART (CMD: 'sudo systemctl restart "${PROJECT_NAME}.service" && sudo systemctl status "${PROJECT_NAME}.service"'): remote: testapp.service - node.js testapp remote: Loaded: loaded (/etc/systemd/system/testapp.service; disabled) remote: Active: inactive (dead) since Fri 2014-03-21 22:10:23 UTC; 10ms ago remote: Process: 9265 ExecStart=/bin/bash -c sleep 3;echo "I am starting";echo "$(whoami)"; (code=exited, status=0/SUCCESS) remote: remote: Mar 21 22:10:20 image systemd[1]: Starting nodejs testapp... remote: Mar 21 22:10:23 image testapp[9265]: I am starting remote: Mar 21 22:10:23 image testapp[9265]: www-data remote: Mar 21 22:10:23 image systemd[1]: Started node.js testapp. remote: remote: ++++++++++++++++++++ See you soon at 'example.com' (1.2.3.4) ++++++++++++++++++++++ To [email protected]:~/testapp 08babc4..95cabcc master -> master $ ``` -
Thomas Fritz revised this gist
Mar 21, 2014 . 1 changed file with 10 additions and 0 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 @@ -0,0 +1,10 @@ all: @echo "Doing all" deploy: @echo "Pushing to production" @git push [email protected]:~/testapp master update: @echo "Makefile: Doing UPDATE stuff like grunt, gulp, rake,..." @whoami -
Thomas Fritz revised this gist
Mar 21, 2014 . 1 changed file with 7 additions and 7 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,23 +1,23 @@ On the server (example.com) ============= 1. Create a user on `example.com`, as which we (the git client) connects (push) to `exmaple.com`. (I am using gid und uid higher than normally because, in case i want to restrict the user later based on the uid, i could then check for uid>10000 or gid>10000 - but you can safely ommit the `-u` and `-g` flags) ```bash sudo groupadd -g 10001 git sudo useradd -u 10001 -g 10001 -d /home/git -m -s /usr/bin/git-shell git ``` 2. Add your ssh public key to the `authorized_keys` file of the created user: ```bash sudo -u git bash cd ~ mkdir -p .ssh vim .ssh/authorized_keys # Paste your public key and save ``` 3. Create a `git bare` repo for your project: ```bash mkdir testapp cd testapp git init --bare -
Thomas Fritz revised this gist
Mar 21, 2014 . 1 changed file with 14 additions and 16 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,8 +1,7 @@ On the server (example.com) ============= 1. Create a user on `example.com`, which we (the git client) use(s) to connect (push). (I am using gid und uid higher than normally because, in case i want to restrict the user later based on the uid, i could then check for uid>10000 or gid>10000 - but you can safely ommit the `-u` and `-g` flags) ```bash sudo groupadd -g 10001 git sudo useradd -u 10001 -g 10001 -d /home/git -m -s /usr/bin/git-shell git @@ -24,7 +23,7 @@ On the server (example.com) git init --bare ``` 4. Copy the `post-receive` script from this gist to the `hooks` dir of the created bare repo. ```bash vim testapp/hooks/post-receive # Paste the script from this gist @@ -41,22 +40,21 @@ On the server (example.com) On the client ============= 6. Create a git repo and add our newly created `remote`: ```bash mkdir testapp cd testapp git init git remote add production [email protected]:~/testapp ``` 7. Commit and push to production: ``` echo "foo" >> test git add . git commit -am "test commit" git push production master ``` -
Thomas Fritz revised this gist
Mar 21, 2014 . 1 changed file with 27 additions and 27 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 @@ -3,39 +3,39 @@ On the server (example.com) 1. Create a user on `example.com`, which we (the git client) use(s) to connect (push). (I am using gid und uid higher than normally because, in case i want to restrict the user later based on the uid, i could then check for uid>10000 or gid>10000 - but you can safely ommit the `-u` and `-g` flags) ```bash sudo groupadd -g 10001 git sudo useradd -u 10001 -g 10001 -d /home/git -m -s /usr/bin/git-shell git ``` 2. Add your ssh public key to `git`s `authorized_keys` file: ```bash mkdir -p /home/git.ssh/ vim /home/git/.ssh/authorized_keys # Paste your public key ``` 3. Create a `git bare` repo for your project: ```bash sudo -u git bash cd ~ mkdir testapp cd testapp git init --bare ``` 4. Copy the `post-receive` script from this gist to the `hooks` dir of the created bare repo. ```bash vim testapp/hooks/post-receive # Paste the script from this gist chmod +x testapp/hooks/post-receive ``` 5. Set ownership and permissions of the `DEPLOY_ROOT` directory: ```bash sudo chown root:git -R /var/www sudo chmod 775 /var/www ``` On the client -
Thomas Fritz revised this gist
Mar 21, 2014 . 1 changed file with 8 additions and 12 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,24 +1,21 @@ On the server (example.com) ============= 1. Create a user on `example.com`, which we (the git client) use(s) to connect (push). (I am using gid und uid higher than normally because, in case i want to restrict the user later based on the uid, i could then check for uid>10000 or gid>10000 - but you can safely ommit the `-u` and `-g` flags) ```bash sudo groupadd -g 10001 git sudo useradd -u 10001 -g 10001 -d /home/git -m -s /usr/bin/git-shell git ``` 2. Add your ssh public key to `git`s `authorized_keys` file: ```bash mkdir -p /home/git.ssh/ vim /home/git/.ssh/authorized_keys # Paste your public key ``` 3. Create a `git bare` repo for your project: ```bash sudo -u git bash cd ~ @@ -27,15 +24,14 @@ cd testapp git init --bare ``` 4. Copy the `post-receive` script from this gist to the `hooks` dir of the created bare repo. ```bash vim testapp/hooks/post-receive # Paste the script from this gist chmod +x testapp/hooks/post-receive ``` 5. Set ownership and permissions of the `DEPLOY_ROOT` directory: ```bash sudo chown root:git -R /var/www sudo chmod 775 /var/www @@ -46,15 +42,15 @@ On the client ============= 6. Create a git repo and add our newly created `remote`: ```bash mkdir testapp cd testapp git init git remote add production [email protected]:~/testapp ``` 7. Commit and push to production: ``` echo "foo" >> test git add . -
Thomas Fritz revised this gist
Mar 21, 2014 . 1 changed file with 17 additions and 4 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 @@ -36,7 +36,6 @@ chmod +x testapp/hooks/post-receive ``` * Set ownership and permissions of the `DEPLOY_ROOT` directory: ```bash sudo chown root:git -R /var/www sudo chmod 775 /var/www @@ -47,10 +46,24 @@ On the client ============= * Create a git repo and add our newly created `remote`: ```bash mkdir testapp cd testapp git init git remote add production [email protected]:~/testapp ``` * Commit and push to production: ``` echo "foo" >> test git add . git commit -am "test commit" git push production master ``` -
Thomas Fritz revised this gist
Mar 21, 2014 . 1 changed file with 14 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 @@ -1,15 +1,15 @@ On the server ============= * Create a user on the server `example.com`, which we (the git client) uses to connect (push). (I am using gid und uid higher than normally because, in case i want to restrict the user later based on the uid, i could then check for uid>10000 or gid>10000 - but you can safely ommit the `-u` and `-g` flags) ```bash sudo groupadd -g 10001 git sudo useradd -u 10001 -g 10001 -d /home/git -m -s /usr/bin/git-shell git ``` * Add your ssh public key to `git`s `authorized_keys` file: ```bash mkdir -p /home/git.ssh/ @@ -44,4 +44,13 @@ sudo chmod 775 /var/www On the client ============= * Create a git repo and add our newly created `remote` ```bash mkdir testapp cd testapp git init git remote add production [email protected]:~/testapp
NewerOlder