gitea.event_name set to push when running scheduled #11875

Closed
opened 2025-11-02 09:50:29 -06:00 by GiteaMirror · 8 comments
Owner

Originally created by @nephatrine on GitHub (Oct 17, 2023).

Description

I have a workflow that runs both on push and on a cron schedule. When I echo ${{ gitea.event_name }} though it shows push both when I push it out and when it runs due to the schedule. From what I can tell, GitHub sets the event_name to schedule when running from a schedule so I expected Gitea to work similarly.

Is this a bug? If not, is there an alternate means to have a workflow detect which trigger it is running under?

Gitea Version

1.21.0-rc1

Can you reproduce the bug on the Gitea demo site?

No

Log Gist

No response

Screenshots

No response

Git Version

2.40

Operating System

alpine:latest

How are you running Gitea?

Gitea self-built and running on a docker image. Recently "updated" from 1.20.5 to 1.21.0-rc1 to for the cron actions.

Database

SQLite

Originally created by @nephatrine on GitHub (Oct 17, 2023). ### Description I have a workflow that runs both on push and on a cron schedule. When I echo `${{ gitea.event_name }}` though it shows `push` both when I push it out and when it runs due to the schedule. From what I can tell, GitHub sets the `event_name` to `schedule` when running from a schedule so I expected Gitea to work similarly. Is this a bug? If not, is there an alternate means to have a workflow detect which trigger it is running under? ### Gitea Version 1.21.0-rc1 ### Can you reproduce the bug on the Gitea demo site? No ### Log Gist _No response_ ### Screenshots _No response_ ### Git Version 2.40 ### Operating System alpine:latest ### How are you running Gitea? Gitea self-built and running on a docker image. Recently "updated" from 1.20.5 to 1.21.0-rc1 to for the cron actions. ### Database SQLite
GiteaMirror added the topic/gitea-actionstype/bug labels 2025-11-02 09:50:29 -06:00
Author
Owner

@lstellway commented on GitHub (Oct 30, 2023):

I see this as well.

gitea v1.21.0-rc1
gitea-runner v0.2.6

Cross-referencing the implementation PR:
https://github.com/go-gitea/gitea/pull/26655

Not entirely sure, but it looks like a schedule value may need to be added here:

So it is returned here:

@lstellway commented on GitHub (Oct 30, 2023): I see this as well. `gitea v1.21.0-rc1` `gitea-runner v0.2.6` Cross-referencing the implementation PR: https://github.com/go-gitea/gitea/pull/26655 Not entirely sure, but it looks like a `schedule` value may need to be added here: - [modules/webhook/type.go#L11-L33](https://github.com/go-gitea/gitea/blob/ec0c6829d4c1096bfa0f9feb52b87b70fba014ea/modules/webhook/type.go#L11-L33) - [modules/webhook/type.go#L37C9-L68](https://github.com/go-gitea/gitea/blob/ec0c6829d4c1096bfa0f9feb52b87b70fba014ea/modules/webhook/type.go#L37C9-L68) So it is returned here: - [routers/api/actions/runner/utils.go#L124-L126](https://github.com/go-gitea/gitea/blob/ec0c6829d4c1096bfa0f9feb52b87b70fba014ea/routers/api/actions/runner/utils.go#L124-L126)
Author
Owner

@fuxiaohei commented on GitHub (Nov 14, 2023):

I test main branch with yaml:

on:
  schedule:
    - cron: "*/5 * * * *"

jobs:
  build:
    runs-on: ubuntu-latest

    steps:
      - name: Make some test files
        run: |
          echo "🎉 The job was automatically triggered by a ${{ github.event_name }} event."
          echo "🎉 The job was automatically triggered by a ${{ gitea.event_name }} event."

Action prints:
image

@fuxiaohei commented on GitHub (Nov 14, 2023): I test main branch with yaml: ```yaml on: schedule: - cron: "*/5 * * * *" jobs: build: runs-on: ubuntu-latest steps: - name: Make some test files run: | echo "🎉 The job was automatically triggered by a ${{ github.event_name }} event." echo "🎉 The job was automatically triggered by a ${{ gitea.event_name }} event." ``` Action prints: <img width="608" alt="image" src="https://github.com/go-gitea/gitea/assets/2142787/82802964-8391-4264-933b-182620860ff1">
Author
Owner

@lunny commented on GitHub (Nov 14, 2023):

So maybe it's a 1.21-only problem.

@lunny commented on GitHub (Nov 14, 2023): So maybe it's a 1.21-only problem.
Author
Owner

@t4skforce commented on GitHub (Nov 27, 2023):

I see this as well.

gitea v1.21.1
act_runner v0.2.6

on:
    push:
    schedule:
        - cron: "*/5 * * * *"

jobs:
    build:
        runs-on: ubuntu-latest

        steps:
            - name: Make some test files
              run: |
                echo "🎉 The job was automatically triggered by a ${{ github.event_name }} event."
                echo "🎉 The job was automatically triggered by a ${{ gitea.event_name }} event."

image

Build via "push"
image

Build via "schedule"
image

It seems the issue is with having two triggers, one on push and one on schedule.

@t4skforce commented on GitHub (Nov 27, 2023): I see this as well. gitea v1.21.1 act_runner v0.2.6 ``` on: push: schedule: - cron: "*/5 * * * *" jobs: build: runs-on: ubuntu-latest steps: - name: Make some test files run: | echo "🎉 The job was automatically triggered by a ${{ github.event_name }} event." echo "🎉 The job was automatically triggered by a ${{ gitea.event_name }} event." ``` ![image](https://github.com/go-gitea/gitea/assets/7422037/0182123d-b7c8-464c-b93d-e23badd4c137) Build via "push" ![image](https://github.com/go-gitea/gitea/assets/7422037/92f3bc03-ef9f-4944-ad31-07fff87c2483) Build via "schedule" ![image](https://github.com/go-gitea/gitea/assets/7422037/6abbf9f1-8b1e-4510-baae-ef941ab9a5ea) It seems the issue is with having two triggers, one on push and one on schedule.
Author
Owner

@henrygoodman commented on GitHub (Nov 28, 2023):

I see this as well.

gitea v1.21.1 act_runner v0.2.6

on:
    push:
    schedule:
        - cron: "*/5 * * * *"

jobs:
    build:
        runs-on: ubuntu-latest

        steps:
            - name: Make some test files
              run: |
                echo "🎉 The job was automatically triggered by a ${{ github.event_name }} event."
                echo "🎉 The job was automatically triggered by a ${{ gitea.event_name }} event."

image

Build via "push" image

Build via "schedule" image

It seems the issue is with having two triggers, one on push and one on schedule.

In the Set up job step, what does it say for the this job was triggered by event: ... (paraphrasing)

@henrygoodman commented on GitHub (Nov 28, 2023): > I see this as well. > > gitea v1.21.1 act_runner v0.2.6 > > ``` > on: > push: > schedule: > - cron: "*/5 * * * *" > > jobs: > build: > runs-on: ubuntu-latest > > steps: > - name: Make some test files > run: | > echo "🎉 The job was automatically triggered by a ${{ github.event_name }} event." > echo "🎉 The job was automatically triggered by a ${{ gitea.event_name }} event." > ``` > > ![image](https://private-user-images.githubusercontent.com/7422037/285757332-0182123d-b7c8-464c-b93d-e23badd4c137.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6Imtle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WID-1n9SwxJrq513CNG33ulzPxD82ofWFCCk8dQ) > > It seems the issue is with having two triggers, one on push and one on schedule. In the `Set up job` step, what does it say for the `this job was triggered by event: ...` (paraphrasing)
Author
Owner

@t4skforce commented on GitHub (Nov 29, 2023):

Build via "push":

act-org-github(version:v0.2.6) received task 713 of job 708, be triggered by event: push
workflow prepared
evaluating expression 'success()'
expression 'success()' evaluated to 'true'

Build via "schedule":

act-org-github(version:v0.2.6) received task 714 of job 709, be triggered by event: push
workflow prepared
evaluating expression 'success()'
expression 'success()' evaluated to 'true'
@t4skforce commented on GitHub (Nov 29, 2023): Build via "push": ``` act-org-github(version:v0.2.6) received task 713 of job 708, be triggered by event: push workflow prepared evaluating expression 'success()' expression 'success()' evaluated to 'true' ``` Build via "schedule": ``` act-org-github(version:v0.2.6) received task 714 of job 709, be triggered by event: push workflow prepared evaluating expression 'success()' expression 'success()' evaluated to 'true' ```
Author
Owner

@phadric commented on GitHub (Dec 11, 2023):

I have the same Problem.
It actually goes a bit further.

For testing I created a new Repo with the following workflow:

.github/workflows/test.yml:

on:
    push:
    schedule:
        - cron: "*/5 * * * *"

jobs:
    build:
        runs-on: ubuntu-latest

        steps:
            - name: Make some test files
              run: |
                echo "🎉 The job was automatically triggered by a ${{ github.event_name }} event."
                echo "🎉 The job was automatically triggered by a ${{ gitea.event_name }} event."

It never gets executed.
Then I create a second workflow:
.github/workflows/push.yml

on:
  push:

jobs:
  build:
    runs-on: ubuntu-latest

    steps:
      - name: Make some test files
        run: |
          echo "🎉 The job was automatically triggered by a ${{ github.event_name }} event."
          echo "🎉 The job was automatically triggered by a ${{ gitea.event_name }} event."   

After this the first workflow is executed every 2 minutes.
I checked my other repos with scheduled Jobs. They seem to use whatever event happened last for github.event_name regardless if they triggered a Workflow or not.

@phadric commented on GitHub (Dec 11, 2023): I have the same Problem. It actually goes a bit further. For testing I created a new Repo with the following workflow: .github/workflows/test.yml: ``` on: push: schedule: - cron: "*/5 * * * *" jobs: build: runs-on: ubuntu-latest steps: - name: Make some test files run: | echo "🎉 The job was automatically triggered by a ${{ github.event_name }} event." echo "🎉 The job was automatically triggered by a ${{ gitea.event_name }} event." ``` It never gets executed. Then I create a second workflow: .github/workflows/push.yml ``` on: push: jobs: build: runs-on: ubuntu-latest steps: - name: Make some test files run: | echo "🎉 The job was automatically triggered by a ${{ github.event_name }} event." echo "🎉 The job was automatically triggered by a ${{ gitea.event_name }} event." ``` After this the first workflow is executed every 2 minutes. I checked my other repos with scheduled Jobs. They seem to use whatever event happened last for github.event_name regardless if they triggered a Workflow or not.
Author
Owner

@Zettat123 commented on GitHub (Mar 1, 2024):

Close this issue since the bug has been fixed by #28691

@Zettat123 commented on GitHub (Mar 1, 2024): Close this issue since the bug has been fixed by #28691
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/gitea#11875