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

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

Closed
mayswind opened this issue May 20, 2023 · 2 comments
Closed
Labels
topic/gitea-actions related to the actions of Gitea type/bug

Comments

@mayswind
Copy link
Contributor

mayswind commented 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

@dboreham
Copy link

Confirmed with manual testing that this is now fixed after merge of #24634 to main.

@mayswind
Copy link
Contributor Author

test the latest version has fixed. close the issue.

lunny pushed a commit that referenced this issue May 30, 2023
…24994)

replace #24868
just a patch to fix #24824 in v1.19.4
The reference name of commits when synchronizing should also has prefix
like refs/heads/<branch-name>.
Codeberg-org pushed a commit to Codeberg-org/gitea that referenced this issue Jun 3, 2023
…o-gitea#24994)

replace go-gitea#24868
just a patch to fix go-gitea#24824 in v1.19.4
The reference name of commits when synchronizing should also has prefix
like refs/heads/<branch-name>.

(cherry picked from commit 826b7b9)
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jul 14, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
topic/gitea-actions related to the actions of Gitea type/bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants