Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save inspiretk/a0aa0aebb98b69af51f86abcd55b6f72 to your computer and use it in GitHub Desktop.
Save inspiretk/a0aa0aebb98b69af51f86abcd55b6f72 to your computer and use it in GitHub Desktop.

Revisions

  1. inspiretk revised this gist Aug 11, 2018. 2 changed files with 12 additions and 8 deletions.
    13 changes: 6 additions & 7 deletions git deploy odoo
    Original file line number Diff line number Diff line change
    @@ -19,11 +19,10 @@ sudo adduser user sudo
    ssh [email protected]
    sudo git init --bare project.git
    cd project.git/hooks
    nano post-receive
    sudo nano post-receive



    # copy/paste the bash script #!/bin/bash
    # copy/paste the bash script #!/bin/bash. Double check your script copy/paste as it does not copy properly.
    # the line while read oldrev newrev ref - ends with ref but copy/paste will make it ref do, so put do on next line
    Copy and paste below script
    #!/bin/bash
    while read oldrev newrev ref
    @@ -32,15 +31,15 @@ do
    if [[ $ref =~ .*/master$ ]];
    then
    echo "Master ref received. Deploying master branch to production..."
    git --work-tree=//odoo/odoo-server/addons/ --git-dir=/home/user/project.git/ checkout -f
    git --work-tree=/odoo/odoo-server/addons/ --git-dir=/home/user/project.git/ checkout -f
    else
    echo "Ref $ref successfully received. Doing nothing: only the master branch may be deployed on this server."
    fi
    done

    # end of file

    chmod +x post-receive
    sudo chmod +x post-receive

    type ls [you'll see post-receive file green meaning it's executable now]

    @@ -60,7 +59,7 @@ cd ~/path/to/working-copy-odoo-addon-folder/

    git init

    git remote add production user@thuani.com:/home/user/project.git
    git remote add production user@cellardrop.com.au:/home/user/project.git

    # To see the new remote that you've added
    git remote -v
    7 changes: 6 additions & 1 deletion z misc
    Original file line number Diff line number Diff line change
    @@ -4,6 +4,10 @@ sudo chown -R user /home/user/project.git
    # ubuntu 18.04 where is git installed
    # ubuntu 18.04 git folder location
    # ubuntu 18.04 give other sudo users git access
    login as root
    visudo


    git --version
    which git
    # give user user git access, odoo acess, and project.git access
    @@ -12,6 +16,7 @@ sudo chown -R user:user /usr/bin/git-receive-pack
    sudo chown -R user:user /usr/bin/git-shell
    sudo chown -R user:user /usr/bin/git-upload-archive
    sudo chown -R user:user /usr/bin/git-upload-pack
    sudo chown -R user:user /odoo
    sudo chown -R user:user /odoo/odoo-server/addons
    sudo chown -R user:user /home/user/project.git
    sudo chown -R user /home/user/project.git

  2. inspiretk revised this gist Aug 11, 2018. 1 changed file with 13 additions and 1 deletion.
    14 changes: 13 additions & 1 deletion z misc
    Original file line number Diff line number Diff line change
    @@ -2,4 +2,16 @@
    sudo chown -R user /home/user/project.git

    # ubuntu 18.04 where is git installed
    git --version
    # ubuntu 18.04 git folder location
    # ubuntu 18.04 give other sudo users git access
    git --version
    which git
    # give user user git access, odoo acess, and project.git access
    sudo chown -R user:user /usr/bin/git
    sudo chown -R user:user /usr/bin/git-receive-pack
    sudo chown -R user:user /usr/bin/git-shell
    sudo chown -R user:user /usr/bin/git-upload-archive
    sudo chown -R user:user /usr/bin/git-upload-pack
    sudo chown -R user:user /odoo
    sudo chown -R user:user /home/user/project.git

  3. inspiretk revised this gist Aug 11, 2018. 1 changed file with 4 additions and 1 deletion.
    5 changes: 4 additions & 1 deletion z misc
    Original file line number Diff line number Diff line change
    @@ -1,2 +1,5 @@
    # give permission to username user to control your git project folder
    sudo chown -R user /home/user/project.git
    sudo chown -R user /home/user/project.git

    # ubuntu 18.04 where is git installed
    git --version
  4. inspiretk revised this gist Aug 10, 2018. 1 changed file with 80 additions and 0 deletions.
    80 changes: 80 additions & 0 deletions git deploy odoo
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,80 @@
    References: https://gist.github.com/noelboss/3fe13927025b89757f8fb12e9066f2fa
    More info: https://www.digitalocean.com/community/tutorials/how-to-use-git-hooks-to-automate-development-and-deployment-tasks
    https://www.youtube.com/watch?v=6mYtJu0E47U
    [misc commands deluser newuser]

    The following steps is for Developers to push their code from their local machine, to their server with git, and let git auto
    pull the update to your remote folder. How it works:
    - From your local machine, you do your normal coding. When done, you push your new code to git
    - Git then updates your local machine, and push it to your server's git
    - Git on your server gets the new update, and push it to your server's working folder

    log to your remote server as normal:

    ssh YourUsername@YourIPorDomain [NOTE: in youtube video https://youtu.be/k3BYVduyjyI I've already added my ssh key and ssh agent in.
    If your server reject you because of ssh key, you'll need to add it into your server. If you don't need ssh key, you'll be fine]

    sudo adduser user
    sudo adduser user sudo
    ssh [email protected]
    sudo git init --bare project.git
    cd project.git/hooks
    nano post-receive



    # copy/paste the bash script #!/bin/bash
    Copy and paste below script
    #!/bin/bash
    while read oldrev newrev ref
    do
    # only checking out the master (or whatever branch you would like to deploy)
    if [[ $ref =~ .*/master$ ]];
    then
    echo "Master ref received. Deploying master branch to production..."
    git --work-tree=//odoo/odoo-server/addons/ --git-dir=/home/user/project.git/ checkout -f
    else
    echo "Ref $ref successfully received. Doing nothing: only the master branch may be deployed on this server."
    fi
    done

    # end of file

    chmod +x post-receive

    type ls [you'll see post-receive file green meaning it's executable now]

    type pwd [make sure your file directory is same as your script]

    # cd into your odoo addon folder
    # pwd to get the folder path
    # cd /odoo/odoo-server/addons
    pwd

    # give user permission for odoo/addons folder

    go to your local computer, and go to the folder you want to git. Use git bash program, and go to the folder if you're on windows

    cd ~/path/to/working-copy-odoo-addon-folder/
    # cd c:/thuani11/addons

    git init

    git remote add production [email protected]:/home/user/project.git

    # To see the new remote that you've added
    git remote -v

    now make a file, add it to your git, commit it and push it to production server

    nano test.txt [then add some text, ctrl x and save it]

    git add .

    git commit -m 'test1'

    git push production master

    now go to your server and go to your deploy folder, you'll see test.txt file in there


  5. inspiretk revised this gist Aug 9, 2018. 1 changed file with 2 additions and 0 deletions.
    2 changes: 2 additions & 0 deletions z misc
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,2 @@
    # give permission to username user to control your git project folder
    sudo chown -R user /home/user/project.git
  6. inspiretk renamed this gist Aug 8, 2018. 1 changed file with 0 additions and 0 deletions.
  7. inspiretk renamed this gist Aug 8, 2018. 1 changed file with 0 additions and 0 deletions.
  8. inspiretk revised this gist Aug 8, 2018. 1 changed file with 40 additions and 0 deletions.
    40 changes: 40 additions & 0 deletions .gitignore default file from odoo
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,40 @@
    # sphinx build directories
    _build/

    # dotfiles
    .*
    !.gitignore
    !.mailmap
    # compiled python files
    *.py[co]
    __pycache__/
    # setup.py egg_info
    *.egg-info
    # emacs backup files
    *~
    # hg stuff
    *.orig
    status
    # odoo filestore
    odoo/filestore
    # maintenance migration scripts
    odoo/addons/base/maintenance

    # generated for windows installer?
    install/win32/*.bat
    install/win32/meta.py

    # needed only when building for win32
    setup/win32/static/less/
    setup/win32/static/wkhtmltopdf/
    setup/win32/static/postgresql*.exe

    # various virtualenv
    /bin/
    /build/
    /dist/
    /include/
    /lib/
    /man/
    /share/
    /src/
  9. inspiretk revised this gist Aug 8, 2018. 1 changed file with 3 additions and 0 deletions.
    3 changes: 3 additions & 0 deletions git auto deploy from local machine to remote server
    Original file line number Diff line number Diff line change
    @@ -58,6 +58,9 @@ git init

    git remote add production [email protected]:/home/user/project.git

    # To see the new remote that you've added
    git remote -v

    now make a file, add it to your git, commit it and push it to production server

    nano test.txt [then add some text, ctrl x and save it]
  10. inspiretk revised this gist Aug 3, 2018. 1 changed file with 4 additions and 2 deletions.
    6 changes: 4 additions & 2 deletions git auto deploy from local machine to remote server
    Original file line number Diff line number Diff line change
    @@ -3,14 +3,16 @@ More info: https://www.digitalocean.com/community/tutorials/how-to-use-git-hooks
    https://www.youtube.com/watch?v=6mYtJu0E47U
    [misc commands deluser newuser]

    The following steps is for Developers to push their code from their local machine, to their server with git, and let git auto pull the update to your remote folder. How it works:
    The following steps is for Developers to push their code from their local machine, to their server with git, and let git auto
    pull the update to your remote folder. How it works:
    - From your local machine, you do your normal coding. When done, you push your new code to git
    - Git then updates your local machine, and push it to your server's git
    - Git on your server gets the new update, and push it to your server's working folder

    log to your remote server as normal:

    ssh YourUsername@YourIPorDomain [NOTE: in youtube video https://youtu.be/k3BYVduyjyI I've already added my ssh key and ssh agent in. If your server reject you because of ssh key, you'll need to add it into your server. If you don't need ssh key, you'll be fine]
    ssh YourUsername@YourIPorDomain [NOTE: in youtube video https://youtu.be/k3BYVduyjyI I've already added my ssh key and ssh agent in.
    If your server reject you because of ssh key, you'll need to add it into your server. If you don't need ssh key, you'll be fine]

    sudo adduser user sudo

  11. inspiretk revised this gist Aug 3, 2018. 1 changed file with 0 additions and 69 deletions.
    69 changes: 0 additions & 69 deletions git auto deploy from local machine to remote server2
    Original file line number Diff line number Diff line change
    @@ -1,69 +0,0 @@
    References: https://gist.github.com/noelboss/3fe13927025b89757f8fb12e9066f2fa
    More info: https://www.digitalocean.com/community/tutorials/how-to-use-git-hooks-to-automate-development-and-deployment-tasks
    https://www.youtube.com/watch?v=6mYtJu0E47U
    [misc commands deluser newuser]

    The following steps is for Developers to push their code from their local machine, to their server with git, and let git auto pull the update to your remote folder. How it works:
    - From your local machine, you do your normal coding. When done, you push your new code to git
    - Git then updates your local machine, and push it to your server's git
    - Git on your server gets the new update, and push it to your server's working folder

    log to your remote server as normal:

    ssh YourUsername@YourIPorDomain [NOTE: in youtube video https://youtu.be/k3BYVduyjyI I've already added my ssh key and ssh agent in. If your server reject you because of ssh key, you'll need to add it into your server. If you don't need ssh key, you'll be fine]

    sudo adduser user sudo

    ssh [email protected]

    mkdir ~/deploy-folder

    git init --bare ~/project.git

    cd ~/project.git/hooks

    nano post-receive

    copy/paste the bash script #!/bin/bash

    Copy and paste below script
    #!/bin/bash
    while read oldrev newrev ref
    do
    # only checking out the master (or whatever branch you would like to deploy)
    if [[ $ref =~ .*/master$ ]];
    then
    echo "Master ref received. Deploying master branch to production..."
    git --work-tree=/home/user/deploy-folder/ --git-dir=/home/user/project.git/ checkout -f
    else
    echo "Ref $ref successfully received. Doing nothing: only the master branch may be deployed on this server."
    fi
    done

    # end of file

    chmod +x post-receive

    type ls [you'll see post-receive file green meaning it's executable now]

    type pwd [make sure your file directory is same as your script]

    go to your local computer, and go to the folder you want to git. Use git bash program, and go to the folder if you're on windows

    cd ~/path/to/working-copy/

    git init

    git remote add production [email protected]:/home/user/project.git

    now make a file, add it to your git, commit it and push it to production server

    nano test.txt [then add some text, ctrl x and save it]

    git add .

    git commit -m 'test1'

    git push production master

    now go to your server and go to your deploy folder, you'll see test.txt file in there
  12. inspiretk revised this gist Aug 3, 2018. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion git auto deploy from local machine to remote server
    Original file line number Diff line number Diff line change
    @@ -1,6 +1,6 @@
    References: https://gist.github.com/noelboss/3fe13927025b89757f8fb12e9066f2fa
    More info: https://www.digitalocean.com/community/tutorials/how-to-use-git-hooks-to-automate-development-and-deployment-tasks
    https://www.youtube.com/watch?v=6mYtJu0E47U
    https://www.youtube.com/watch?v=6mYtJu0E47U
    [misc commands deluser newuser]

    The following steps is for Developers to push their code from their local machine, to their server with git, and let git auto pull the update to your remote folder. How it works:
  13. inspiretk revised this gist Aug 3, 2018. No changes.
  14. inspiretk revised this gist Aug 3, 2018. 1 changed file with 69 additions and 0 deletions.
    69 changes: 69 additions & 0 deletions git auto deploy from local machine to remote server2
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,69 @@
    References: https://gist.github.com/noelboss/3fe13927025b89757f8fb12e9066f2fa
    More info: https://www.digitalocean.com/community/tutorials/how-to-use-git-hooks-to-automate-development-and-deployment-tasks
    https://www.youtube.com/watch?v=6mYtJu0E47U
    [misc commands deluser newuser]

    The following steps is for Developers to push their code from their local machine, to their server with git, and let git auto pull the update to your remote folder. How it works:
    - From your local machine, you do your normal coding. When done, you push your new code to git
    - Git then updates your local machine, and push it to your server's git
    - Git on your server gets the new update, and push it to your server's working folder

    log to your remote server as normal:

    ssh YourUsername@YourIPorDomain [NOTE: in youtube video https://youtu.be/k3BYVduyjyI I've already added my ssh key and ssh agent in. If your server reject you because of ssh key, you'll need to add it into your server. If you don't need ssh key, you'll be fine]

    sudo adduser user sudo

    ssh [email protected]

    mkdir ~/deploy-folder

    git init --bare ~/project.git

    cd ~/project.git/hooks

    nano post-receive

    copy/paste the bash script #!/bin/bash

    Copy and paste below script
    #!/bin/bash
    while read oldrev newrev ref
    do
    # only checking out the master (or whatever branch you would like to deploy)
    if [[ $ref =~ .*/master$ ]];
    then
    echo "Master ref received. Deploying master branch to production..."
    git --work-tree=/home/user/deploy-folder/ --git-dir=/home/user/project.git/ checkout -f
    else
    echo "Ref $ref successfully received. Doing nothing: only the master branch may be deployed on this server."
    fi
    done

    # end of file

    chmod +x post-receive

    type ls [you'll see post-receive file green meaning it's executable now]

    type pwd [make sure your file directory is same as your script]

    go to your local computer, and go to the folder you want to git. Use git bash program, and go to the folder if you're on windows

    cd ~/path/to/working-copy/

    git init

    git remote add production [email protected]:/home/user/project.git

    now make a file, add it to your git, commit it and push it to production server

    nano test.txt [then add some text, ctrl x and save it]

    git add .

    git commit -m 'test1'

    git push production master

    now go to your server and go to your deploy folder, you'll see test.txt file in there
  15. inspiretk revised this gist Aug 3, 2018. No changes.
  16. inspiretk revised this gist Aug 3, 2018. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion git auto deploy from local machine to remote server
    Original file line number Diff line number Diff line change
    @@ -10,7 +10,7 @@ The following steps is for Developers to push their code from their local machin

    log to your remote server as normal:

    ssh YourUsername@YourIPorDomain
    ssh YourUsername@YourIPorDomain [NOTE: in youtube video https://youtu.be/k3BYVduyjyI I've already added my ssh key and ssh agent in. If your server reject you because of ssh key, you'll need to add it into your server. If you don't need ssh key, you'll be fine]

    sudo adduser user sudo

  17. inspiretk revised this gist Aug 3, 2018. 2 changed files with 2 additions and 2 deletions.
    2 changes: 1 addition & 1 deletion git auto deploy from local machine to remote server
    Original file line number Diff line number Diff line change
    @@ -34,7 +34,7 @@ do
    if [[ $ref =~ .*/master$ ]];
    then
    echo "Master ref received. Deploying master branch to production..."
    git --work-tree=/home/user/deploy-folder/ --git-dir=/home/user/repo.git/ checkout -f
    git --work-tree=/home/user/deploy-folder/ --git-dir=/home/user/project.git/ checkout -f
    else
    echo "Ref $ref successfully received. Doing nothing: only the master branch may be deployed on this server."
    fi
    2 changes: 1 addition & 1 deletion z Copy and Paste this to file post-receive
    Original file line number Diff line number Diff line change
    @@ -5,7 +5,7 @@ do
    if [[ $ref =~ .*/master$ ]];
    then
    echo "Master ref received. Deploying master branch to production..."
    git --work-tree=/home/inspire/deploy-folder/ --git-dir=/home/inspire/repo.git/ checkout -f
    git --work-tree=/home/user/deploy-folder/ --git-dir=/home/user/project.git/ checkout -f
    else
    echo "Ref $ref successfully received. Doing nothing: only the master branch may be deployed on this server."
    fi
  18. inspiretk revised this gist Aug 3, 2018. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion git auto deploy from local machine to remote server
    Original file line number Diff line number Diff line change
    @@ -34,7 +34,7 @@ do
    if [[ $ref =~ .*/master$ ]];
    then
    echo "Master ref received. Deploying master branch to production..."
    git --work-tree=/home/inspire/deploy-folder/ --git-dir=/home/inspire/repo.git/ checkout -f
    git --work-tree=/home/user/deploy-folder/ --git-dir=/home/user/repo.git/ checkout -f
    else
    echo "Ref $ref successfully received. Doing nothing: only the master branch may be deployed on this server."
    fi
  19. inspiretk revised this gist Aug 3, 2018. No changes.
  20. inspiretk revised this gist Aug 3, 2018. 1 changed file with 2 additions and 1 deletion.
    3 changes: 2 additions & 1 deletion git auto deploy from local machine to remote server
    Original file line number Diff line number Diff line change
    @@ -1,6 +1,7 @@
    References: https://gist.github.com/noelboss/3fe13927025b89757f8fb12e9066f2fa
    More info: https://www.digitalocean.com/community/tutorials/how-to-use-git-hooks-to-automate-development-and-deployment-tasks
    https://www.youtube.com/watch?v=6mYtJu0E47U
    [misc commands deluser newuser]

    The following steps is for Developers to push their code from their local machine, to their server with git, and let git auto pull the update to your remote folder. How it works:
    - From your local machine, you do your normal coding. When done, you push your new code to git
    @@ -9,7 +10,7 @@ The following steps is for Developers to push their code from their local machin

    log to your remote server as normal:

    ssh root@ip
    ssh YourUsername@YourIPorDomain

    sudo adduser user sudo

  21. inspiretk revised this gist Aug 3, 2018. 1 changed file with 7 additions and 1 deletion.
    8 changes: 7 additions & 1 deletion git auto deploy from local machine to remote server
    Original file line number Diff line number Diff line change
    @@ -1,7 +1,13 @@
    References: https://gist.github.com/noelboss/3fe13927025b89757f8fb12e9066f2fa
    More info: https://www.digitalocean.com/community/tutorials/how-to-use-git-hooks-to-automate-development-and-deployment-tasks
    https://www.youtube.com/watch?v=6mYtJu0E47U
    log to your remote server root user

    The following steps is for Developers to push their code from their local machine, to their server with git, and let git auto pull the update to your remote folder. How it works:
    - From your local machine, you do your normal coding. When done, you push your new code to git
    - Git then updates your local machine, and push it to your server's git
    - Git on your server gets the new update, and push it to your server's working folder

    log to your remote server as normal:

    ssh root@ip

  22. inspiretk renamed this gist Aug 3, 2018. 1 changed file with 0 additions and 0 deletions.
  23. inspiretk revised this gist Aug 3, 2018. 1 changed file with 2 additions and 1 deletion.
    3 changes: 2 additions & 1 deletion FOLLOW THESE STEPS
    Original file line number Diff line number Diff line change
    @@ -1,5 +1,6 @@
    References: https://gist.github.com/noelboss/3fe13927025b89757f8fb12e9066f2fa

    More info: https://www.digitalocean.com/community/tutorials/how-to-use-git-hooks-to-automate-development-and-deployment-tasks
    https://www.youtube.com/watch?v=6mYtJu0E47U
    log to your remote server root user

    ssh root@ip
  24. inspiretk revised this gist Aug 3, 2018. 1 changed file with 2 additions and 0 deletions.
    2 changes: 2 additions & 0 deletions FOLLOW THESE STEPS
    Original file line number Diff line number Diff line change
    @@ -1,3 +1,5 @@
    References: https://gist.github.com/noelboss/3fe13927025b89757f8fb12e9066f2fa

    log to your remote server root user

    ssh root@ip
  25. inspiretk revised this gist Aug 3, 2018. 1 changed file with 2 additions and 0 deletions.
    2 changes: 2 additions & 0 deletions FOLLOW THESE STEPS
    Original file line number Diff line number Diff line change
    @@ -1,5 +1,7 @@
    log to your remote server root user

    ssh root@ip

    sudo adduser user sudo

    ssh [email protected]
  26. inspiretk renamed this gist Aug 3, 2018. 1 changed file with 0 additions and 0 deletions.
  27. inspiretk renamed this gist Aug 3, 2018. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  28. inspiretk revised this gist Aug 3, 2018. 1 changed file with 12 additions and 0 deletions.
    12 changes: 12 additions & 0 deletions Copy and Paste this to file post-receive
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,12 @@
    #!/bin/bash
    while read oldrev newrev ref
    do
    # only checking out the master (or whatever branch you would like to deploy)
    if [[ $ref =~ .*/master$ ]];
    then
    echo "Master ref received. Deploying master branch to production..."
    git --work-tree=/home/inspire/deploy-folder/ --git-dir=/home/inspire/repo.git/ checkout -f
    else
    echo "Ref $ref successfully received. Doing nothing: only the master branch may be deployed on this server."
    fi
    done
  29. inspiretk created this gist Aug 3, 2018.
    59 changes: 59 additions & 0 deletions gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,59 @@
    log to your remote server root user

    sudo adduser user sudo

    ssh [email protected]

    mkdir ~/deploy-folder

    git init --bare ~/project.git

    cd ~/project.git/hooks

    nano post-receive

    copy/paste the bash script #!/bin/bash

    Copy and paste below script
    #!/bin/bash
    while read oldrev newrev ref
    do
    # only checking out the master (or whatever branch you would like to deploy)
    if [[ $ref =~ .*/master$ ]];
    then
    echo "Master ref received. Deploying master branch to production..."
    git --work-tree=/home/inspire/deploy-folder/ --git-dir=/home/inspire/repo.git/ checkout -f
    else
    echo "Ref $ref successfully received. Doing nothing: only the master branch may be deployed on this server."
    fi
    done

    # end of file

    chmod +x post-receive

    type ls [you'll see post-receive file green meaning it's executable now]

    type pwd [make sure your file directory is same as your script]

    go to your local computer, and go to the folder you want to git. Use git bash program, and go to the folder if you're on windows

    cd ~/path/to/working-copy/

    git init

    git remote add production [email protected]:/home/user/project.git

    now make a file, add it to your git, commit it and push it to production server

    nano test.txt [then add some text, ctrl x and save it]

    git add .

    git commit -m 'test1'

    git push production master

    now go to your server and go to your deploy folder, you'll see test.txt file in there