Git, upload code directly to the server

Asked

Viewed 687 times

2

I wanted to know if it is possible a way to leave all my projects online so that I don’t keep modifying my code to upload it to the server.

Go some questions:

  • I use git, wanted to use a branch for each development environment, in this case it would be the best alternative?

  • Now with every update in the code I wanted to upload it straight to the server with push (GIT), without having to do manual uploads to the server. Like github, but it doesn’t interpret PHP code, just front-end, this is why I want to go straight to the server.


I don’t know if this is the best place to post this, but I hope so, thank you!


Updating

I found a blog where the guy teaches, Link
I’ll leave it open for anyone who wants to put their answer, but this question is duplicated, I don’t know if I should delete it?!


@egomesbrandao is talking about this?

inserir a descrição da imagem aqui


My solution

My server plan is free, but it supports SSH, but in my plan (free) it is disabled. So I went to this link "Github git-ftp" and did according to the documentation.
Since my plan does not accept SSH I did by FTP even, but now I do not need to put FTP user and password whenever I update, just do this(user and password) once and give a "git push". This little program is slow, but automating the tasks already saves a nice time!

Thanks for the answers!

  • What is your workflow like until it comes into production? To suggest something more suitable.

  • You mean using git similar to FTP?

  • Yeah, git similar to FTP @Andersoncarloswoss

  • You want to deploy your application using git?

  • That’s like deploy, sorry I can’t explain, I’m not very advanced in git. @devsimoes

  • Yes, it is possible to do this, and in my humble opinion is much better than using ftp, but you will need to configure the ssh connection on your server, many hosting servers already offer this option and even already come as the ready deploy option, as is the case with umbler.com, finally, another user has already asked a question similar to yours, take a look: http://answall.com/questions/82475/deploy-autom%C3%A1tico-ap%C3%B3s-git-push

  • Would you recommend this? https://medium.com/@wesleysaraujo/deploy-com-git-configurando-e-executando-um-deploy-automatizado-156e3e1bc374#. 3easdunw2 @Jonathanfreitas

  • Yes, he’s very detailed.

  • 1

    Ah, when it comes to creating the *.git folder by using the mkdir app.git && cd app.git command, for security reasons, ideally do this outside the public folder or www, in a directory where the user cannot access it.

  • Got it, thanks! @Jonathanfreitas

  • @Jonathanfreitas has how to do this without using SSH ?

  • What you want to do is: After each commit is in the repository, automatically publish the new version on a given server and for each server you want to use a brench, that’s it?

  • @Intruder I’ll give you an example. For development environment. use the master branch, and for the production "host". Or it could be the master for both of us, what I want is to end this by manually uploading to my server. I want a push or even a commit to deploy, my hosting plan does not allow me access to ssh ;/

  • Yes, in addition to SSH, you can use the FTP protocol with GIT, with the git ftp push command, but for that, you need to use git-ftp on your local machine. http://git-ftp.github.io/git-ftp/

Show 9 more comments

1 answer

3


No! Using a branch for each environment is not the best alternative, it’s called code promotion; and that technique is no longer used. The idea is to promote binaries or artifacts generated in a build process. Since PHP is not a language that generates binaries, what you will promote are the artifacts that will basically be the same files, but with some peculiarities.

Imagine you have a database connection string. In a good pipeline you would have a bank for each environment, for that you would have to have a string for each one, it makes no sense to have to change the code for each environment. Then a tokenization process is used in the configuration file to replace the contents of the string for each environment that deploys. This is just one of the techniques, so it’s called build and deploy process, there are several tasks you will perform to complete this process.

Another practice would be to push the Git repository, fire the whole process up, and not put a Git into the deploy server, it’s even an anti-pattern to do this.

For all this pipeline automation there are tools like Trevis CI, Hudson, etc...

Browser other questions tagged

You are not signed in. Login or sign up in order to post.