P
P
Pavel Voronyuk2017-08-02 01:03:31
Software Deployment
Pavel Voronyuk, 2017-08-02 01:03:31

How to automate deploy from GitHub to Hosting?

Hi all.
For two days I figured out how to deploy from GitHub to hosting. Understood.
1. I created an SSH public key on the hosting, added it to the GitHub settings.
2. Connect:

$ ssh -T [email protected]
Hi pawlek! You've successfully authenticated, but GitHub does not provide shell access.

3. To make a deployment from GitHub, I write:
$ cd example.com/www/
$ git checkout master
$ git pull

How to do everything in one command? for example
$ ssh <command>
And in ideal how to do an automatic check if there was a marge in the master branch, and if so, make a deployment to the hosting?
My hands are probably crooked or I don’t understand something from what is described here - nano.sapegin.ru/all/deploy
Thanks for the help)

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vladimir Mukovoz, 2017-08-02
@castomi

Write a bash script that will do all this, and for automation push it into cron.

sshpass -pPASSWORD ssh -T [email protected] cd example.com/www;git checkout master;git pull

Naturally, for such an execution, you must first install sshpass
apt install sshpass
Although you can do without it, you will need to enter a password
ssh -T [email protected] cd example.com/www;git checkout master;git pull

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question