Action cannot be triggered after the mirror repository is synchronized #10883

Closed
opened 2025-11-02 09:21:06 -06:00 by GiteaMirror · 2 comments
Owner

Originally created by @mayswind on GitHub (May 20, 2023).

Description

The action workflow cannot be triggered after the mirror repository is synchronized when the workflow has branch filter parameters (see the below code)

on:
  push:
    branches:
      - main

But when the workflow does not have any filter parameters (see the below code), the workflow can be triggered.

on:
  push

The reproduce steps:

  1. Setup a new mirror repository (the upstream repository should have a workflow file like the first code at the above)
  2. Enable actions for this repository
  3. Push a new commit to the upstream repository
  4. Sync the mirror repository
  5. The workflow would not be triggered

I check the log file (log level is set to trace), and find these logs

2023/05/20 21:26:05 ...actions/workflows.go:86:DetectWorkflows() [T] detect workflow "docker-release.yml" for event &jobparser.Event{Name:"push", acts:map[string][]string{"tags":[]string{"v*"}}, schedules:[]map[string]string(nil)} matching "push"
2023/05/20 21:26:05 ...actions/workflows.go:86:DetectWorkflows() [T] detect workflow "docker-snapshot.yml" for event &jobparser.Event{Name:"push", acts:map[string][]string{"branches":[]string{"main"}}, schedules:[]map[string]string(nil)} matching "push"
2023/05/20 21:26:05 ...s/notifier_helper.go:146:notify() [T] repo /data/git/repositories/****/****.git with commit 2d290990bfed049db1056432379fc54755bcb85e couldn't find workflows

So I check the code in modules/actions/workflows.go:200. The variable refName does not contain git.BranchPrefix (refs/heads/), so the workflow would not be triggered after the repository is synchronized if the workflow file has branch filter.

Then I check the results variable in services/mirror/mirror_pull.go:413, the field refName also does not contain git.BranchPrefix.

Gitea Version

Test in v1.19.3 and latest commit #1698c15cba8f9eedfcb6af8226f3e97950480aca

Can you reproduce the bug on the Gitea demo site?

No

Log Gist

No response

Screenshots

No response

Git Version

2.40.1

Operating System

Debian 11

How are you running Gitea?

I use the gitea/gitea:1.19.3 docker image to run gitea. To verify whether the latest version has fixed this issue, I download the latest code, and execute TAGS="bindata sqlite sqlite_unlock_notify" make build (the golang version is 1.20.4, the nodejs version is 18.16.0) to build the latest binary file and put it into gitea/gitea:1.19.3 image, then use the modified image to test.

Database

MySQL

Originally created by @mayswind on GitHub (May 20, 2023). ### Description The action workflow cannot be triggered after the mirror repository is synchronized when the workflow has branch filter parameters (see the below code) ``` on: push: branches: - main ``` But when the workflow does not have any filter parameters (see the below code), the workflow can be triggered. ``` on: push ``` The reproduce steps: 1. Setup a new mirror repository (the upstream repository should have a workflow file like the first code at the above) 2. Enable actions for this repository 3. Push a new commit to the upstream repository 4. Sync the mirror repository 5. The workflow would not be triggered I check the log file (log level is set to `trace`), and find these logs ``` 2023/05/20 21:26:05 ...actions/workflows.go:86:DetectWorkflows() [T] detect workflow "docker-release.yml" for event &jobparser.Event{Name:"push", acts:map[string][]string{"tags":[]string{"v*"}}, schedules:[]map[string]string(nil)} matching "push" 2023/05/20 21:26:05 ...actions/workflows.go:86:DetectWorkflows() [T] detect workflow "docker-snapshot.yml" for event &jobparser.Event{Name:"push", acts:map[string][]string{"branches":[]string{"main"}}, schedules:[]map[string]string(nil)} matching "push" 2023/05/20 21:26:05 ...s/notifier_helper.go:146:notify() [T] repo /data/git/repositories/****/****.git with commit 2d290990bfed049db1056432379fc54755bcb85e couldn't find workflows ``` So I check the code in [`modules/actions/workflows.go:200`](https://github.com/go-gitea/gitea/blob/1698c15cba8f9eedfcb6af8226f3e97950480aca/modules/actions/workflows.go#L200). The variable `refName` does not contain `git.BranchPrefix` (`refs/heads/`), so the workflow would not be triggered after the repository is synchronized if the workflow file has branch filter. Then I check the `results` variable in [`services/mirror/mirror_pull.go:413`](https://github.com/go-gitea/gitea/blob/1698c15cba8f9eedfcb6af8226f3e97950480aca/services/mirror/mirror_pull.go#L413), the field `refName` also does not contain `git.BranchPrefix`. ### Gitea Version Test in v1.19.3 and latest commit #1698c15cba8f9eedfcb6af8226f3e97950480aca ### Can you reproduce the bug on the Gitea demo site? No ### Log Gist _No response_ ### Screenshots _No response_ ### Git Version 2.40.1 ### Operating System Debian 11 ### How are you running Gitea? I use the `gitea/gitea:1.19.3` docker image to run gitea. To verify whether the latest version has fixed this issue, I download the latest code, and execute `TAGS="bindata sqlite sqlite_unlock_notify" make build` (the golang version is 1.20.4, the nodejs version is 18.16.0) to build the latest binary file and put it into `gitea/gitea:1.19.3` image, then use the modified image to test. ### Database MySQL
GiteaMirror added the topic/gitea-actionstype/bug labels 2025-11-02 09:21:06 -06:00
Author
Owner

@dboreham commented on GitHub (May 26, 2023):

Confirmed with manual testing that this is now fixed after merge of https://github.com/go-gitea/gitea/pull/24634 to main.

@dboreham commented on GitHub (May 26, 2023): Confirmed with manual testing that this is now fixed after merge of https://github.com/go-gitea/gitea/pull/24634 to main.
Author
Owner

@mayswind commented on GitHub (May 29, 2023):

test the latest version has fixed. close the issue.

@mayswind commented on GitHub (May 29, 2023): test the latest version has fixed. close the issue.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/gitea#10883