Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Push-to-deploy #264

Closed
tubia opened this issue Jun 27, 2014 · 9 comments
Closed

Push-to-deploy #264

tubia opened this issue Jun 27, 2014 · 9 comments
Labels
🎯 feature Categorizes as related to a new feature

Comments

@tubia
Copy link

tubia commented Jun 27, 2014

Hi,
is possible to use gogs in a psuh-to-deploy system?
What I would like to achieve is that when you push to gogs, all the files are copied to 'production/' folder (in the same server).

Is this possible?

@lunny
Copy link
Contributor

lunny commented Jun 27, 2014

It's possible. But gogs currently does not provide this feature.

@unknwon
Copy link
Member

unknwon commented Jun 27, 2014

This feature someone else has asked before, it will be implemented.

@tubia
Copy link
Author

tubia commented Jul 11, 2014

A little how-to for a server-side workaround, waiting for a possible gogs feature :)

  1. connect to the server where gogs is installed and move to the gogs/ folder
  2. cd inside the repositories folder, the default is repos
  3. move to the user and then to the specific repo where you want the push-to-deploy, ex. cd doe/mycode.git
  4. if you list ls you should see a hooks folder: this is where different hooks are located. You can learn more about git hooks here or here
  5. inside hooks/ there are different .sample files, we need post-receive.sample. Renames it deleting the .sample cp post-receive.sample post-receive.
  6. Now we need to actually add the script that will be executed after every push. So, vim post-receive and insert:
#!/bin/sh
git --work-tree=/var/www/html/mycode --git-dir=/var/www/html/gogs/repos/doe/mycode.git checkout -f

That's all!

@unknwon
Copy link
Member

unknwon commented Jul 11, 2014

Wow, looks great!

@unknwon unknwon removed the Future label Jul 11, 2014
@lunny
Copy link
Contributor

lunny commented Jul 12, 2014

We don't use git's post-receive hook. But we can add a hook in gogs serve.

@unknwon
Copy link
Member

unknwon commented Jul 12, 2014

These things can actually happen in the CommitRepoAction.

@unknwon
Copy link
Member

unknwon commented Oct 6, 2014

Hi @tubia , I just pushed code to dev branch for Git hooks support, for security reason, it's disabled by default, you need to change config option service -> ENABLE_GIT_HOOKS = true and restart Gogs to be able to see it in repository setting page.

Any feedback is welcome!

@unknwon unknwon closed this as completed in 64c6822 Oct 6, 2014
@tubia
Copy link
Author

tubia commented Oct 18, 2014

Hi @unknwon sounds great :)
I'll give it a try ASAP!

@avks
Copy link

avks commented Aug 6, 2016

hi @tubia, your solution works like a charm. All I needed to do was: chmod +x post-receive!

ethantkoenig pushed a commit to ethantkoenig/gogs that referenced this issue Nov 27, 2016
unknwon pushed a commit to gogs/docs that referenced this issue Jan 22, 2017
* Added ENABLE_GIT_HOOKS setting to cheat sheet

As mentioned in [issue 264](gogs/gogs#264) of the gogs main repo, gogs contains a dedicated setting to allow the execution of git hooks which wasn't reflected in the documentation until now.

* Added German translation to previous commit

* Added French translation to previous commit
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 25, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
🎯 feature Categorizes as related to a new feature
Projects
None yet
Development

No branches or pull requests

4 participants