Are any of the git-hooks called when repo is mirrored to Gitea?

Really just the title, I was wondering if any of the git-hooks (update or post-receive) are called (or are supposed to be called) after a repo has been synced from another source?

I’d like to deploy the files to a folder after the sync has occurred.

@tarasis Did you ever find and answer to this?

I have a post-recieve script I normally use to deploy web sites from Gitea but it doesn’t fire when the repository is a mirror that gets pushed too from another instance. The push is successfully occurring - not sure the script is running.

Or possibly it is running but not working, it relies on parsing the branch name from refname:

while read oldrev newrev refname
branch=$(git rev-parse --symbolic --abbrev-ref $refname)

if [ "production" == "$branch" ]; then

if [ -d "${git_work_tree}"/production ]; then
git_clean production
git_checkout production
create_work_dir production
git_checkout production

I suppose I need to dig into the git repos on the server and check logs…

Answering my own question: Yes the git hooks are called.

(Problems are in my script)

Hi @adrinux and @tarasis Did you manage to fire a git hook for a mirrored repo?

See my previous post.

tldr: yes

Thank you for the confirmation @adrinux.

When I click on the “Synchronize Now” button to force the sync.

I can’t see the post-receive action in the logs.

but when I try with a no-mirrored repo, after a push, I can see clearly the post-receive.
completed POST /api/internal/hook/post-receive/xxxx/hooktesting

Any idea?

Thank you :slight_smile:

I don’t recognise that table & button @steevex35 and webhooks use POST requests – I suspect you’re working with a webhook, not a git-hook.

If so this thread and my experience will be irrelevant.

Alright, thanks again for your answer :slight_smile:

Resurecting this tread.

I tried to configure a git hook for a mirrored repo but It seems it never gets triggered on mirroring/sync action.

I added several test scripts in some of the git hooks ( pre-receive, update, post-receive).
The things I tried inside the scripts
1: create a test folder (with mkdir)
2: create a new branch
3: exit 1 (which should block the process if set on pre-receive git hook).

All of these worked just fine when I pushed into a repo (so I would say the actual script content is not the issue) but nothing worked on the mirrored repo.

I’m using Gitea on Docker Version: 1.21.0 (with MySql).

Any ideas? Does GITEA support git hooks on mirror/sync?