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

gitea.event_name set to push when running scheduled #27667

Closed
nephatrine opened this issue Oct 17, 2023 · 8 comments
Closed

gitea.event_name set to push when running scheduled #27667

nephatrine opened this issue Oct 17, 2023 · 8 comments
Labels
topic/gitea-actions related to the actions of Gitea type/bug

Comments

@nephatrine
Copy link
Contributor

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

@lunny lunny added the topic/gitea-actions related to the actions of Gitea label Oct 18, 2023
@lstellway
Copy link

I see this as well.

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

Cross-referencing the implementation PR:
#26655

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

So it is returned here:

@fuxiaohei
Copy link
Contributor

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

@lunny
Copy link
Member

lunny commented Nov 14, 2023

So maybe it's a 1.21-only problem.

@t4skforce
Copy link

t4skforce commented 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.

@henrygoodman
Copy link
Contributor

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)

@t4skforce
Copy link

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'

@phadric
Copy link

phadric commented 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.

sergcpp added a commit to sergcpp/RayDemo that referenced this issue Dec 18, 2023
@Zettat123
Copy link
Contributor

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

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 12, 2024
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

No branches or pull requests

8 participants