Workflow with on.push.paths triggers only on second push #11384

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

Originally created by @nblock on GitHub (Aug 1, 2023).

Description

The following workflow configuration file should trigger on push events to any branch where files anywhere below dir2/ got changed.

---
name: Run only on changes within dir2

on:
  push:
    paths:
      - dir2/**

jobs:
  dir2:
    runs-on: playground
    steps:
      - name: Step for files in dir2
        run: |
          echo 'something changed'

With Gitea 1.20.2 and act runner 0.2.4 this works when pushing a commit that modifies files in dir2/ and the branch already exists on the remote (e.g. the branch main).

It does not work when a new commit that modifies files in dir2/ is pushed to a new branch on the remote. The event is silently ignored. However, the workflow triggers when pushing a second commit to the same branch.

Gitea Version

1.20.2

Can you reproduce the bug on the Gitea demo site?

No

Log Gist

No response

Screenshots

No response

Git Version

git version 2.39.2

Operating System

Debian 12

How are you running Gitea?

Official release supervised by systemd.

Database

PostgreSQL

Originally created by @nblock on GitHub (Aug 1, 2023). ### Description The following workflow configuration file [should trigger on push events to any branch where files anywhere below `dir2/` got changed](https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#example-including-paths). ```yml --- name: Run only on changes within dir2 on: push: paths: - dir2/** jobs: dir2: runs-on: playground steps: - name: Step for files in dir2 run: | echo 'something changed' ``` With Gitea 1.20.2 and act runner 0.2.4 this works when pushing a commit that modifies files in `dir2/` and the branch already exists on the remote (e.g. the branch `main`). It does not work when a new commit that modifies files in `dir2`/ is pushed to a new branch on the remote. The event is silently ignored. However, the workflow triggers when pushing a second commit to the same branch. ### Gitea Version 1.20.2 ### Can you reproduce the bug on the Gitea demo site? No ### Log Gist _No response_ ### Screenshots _No response_ ### Git Version git version 2.39.2 ### Operating System Debian 12 ### How are you running Gitea? Official release supervised by systemd. ### Database PostgreSQL
GiteaMirror added the topic/gitea-actionstype/bug labels 2025-11-02 09:36:13 -06:00
Author
Owner

@CaiCandong commented on GitHub (Aug 2, 2023):

I was able to reproduce your problem and I'm trying to locate the bug.

@CaiCandong commented on GitHub (Aug 2, 2023): I was able to reproduce your problem and I'm trying to locate the bug.
Author
Owner

@CaiCandong commented on GitHub (Aug 2, 2023):

I found out why this problem occurs, when you push a new branch, OldCommitID is a null value.

image

Where the error occurred:
54c28fddd8/modules/actions/workflows.go (L256-L260)

It seems that OldCommitID for new branches is a null value that seems to be designed.

54c28fddd8/services/repository/push.go (L132-L148)

@CaiCandong commented on GitHub (Aug 2, 2023): I found out why this problem occurs, when you push a new branch, `OldCommitID` is a null value. ![image](https://github.com/go-gitea/gitea/assets/50507092/19b86a6d-7f04-454d-8910-63d77bab15bc) Where the error occurred: https://github.com/go-gitea/gitea/blob/54c28fddd8a407c3ddea81923bb2978c33ef020d/modules/actions/workflows.go#L256-L260 ~~It seems that `OldCommitID` for new branches is a null value that seems to be designed.~~ ~~https://github.com/go-gitea/gitea/blob/54c28fddd8a407c3ddea81923bb2978c33ef020d/services/repository/push.go#L132-L148~~
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/gitea#11384