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

ref_name in actions sometimes blank for scheduled jobs #27678

Closed
nephatrine opened this issue Oct 18, 2023 · 7 comments · Fixed by #28640
Closed

ref_name in actions sometimes blank for scheduled jobs #27678

nephatrine opened this issue Oct 18, 2023 · 7 comments · Fixed by #28640
Labels
issue/confirmed Issue has been reviewed and confirmed to be present or accepted to be implemented topic/gitea-actions related to the actions of Gitea type/bug
Milestone

Comments

@nephatrine
Copy link
Contributor

Description

When my actions jobs are running, both ${{ gitea.ref_name }} and ${GITHUB_REF##*/} are empty for some repositories when running from the cron schedule (but work fine during push trigger). When I tried to make a new repo with a minimal test, I was unable to reproduce this issue but it is consistently the case for my existing repos. I slowly built up that minimal example until it was essentially the same as my existing job and it still returned the correct result. I've ran this instance for a while and so those existing repos were created in earlier gitea versions and that's the only thing I can think of that would make them different than a new repo. Any idea on what could cause this behavior and if there is something specific I need to look for and correct in the database maybe for those repos migrated from earlier versions?

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?

self-built in a docker container

Database

SQLite

@nephatrine
Copy link
Contributor Author

nephatrine commented Oct 18, 2023

In the Actions UI, it doesn't show the branch name for those particular scheduled jobs either (the top one is schedule and bottom is the push).
image

@techknowlogick techknowlogick added the topic/gitea-actions related to the actions of Gitea label Oct 19, 2023
@lng2020
Copy link
Member

lng2020 commented Oct 19, 2023

In the Actions UI, it doesn't show the branch name for those particular scheduled jobs either

That's a known issue.

@nephatrine
Copy link
Contributor Author

Oh ok. I swear I looked around in the issues, but didn't see it reported already.

@ExplodingDragon
Copy link
Contributor

link #26815

@nephatrine
Copy link
Contributor Author

I guess I must not have looked at closed issues. My main issue isn't that it doesn't show up in the UI, it's that I need the value in my actual action and it's not setting the variables. So far the only way I've found to "resolve" this is to try removing and recreating all my existing repos which isn't something I'm really excited about trying to do.

@nephatrine
Copy link
Contributor Author

So after more experimentation, repo I created as a minimal testcase still hasn't encountered the issue, but other new brand new repos do have this issue. It's nice in some ways because it is a reliable way for me to differentiate push and schedule events in my workflows in light of #27667, but it's all the more vexing to me why it would impact every single one of my repos... except the minimal example. I'll keep playing around and see if maybe something about the workflow size or complexity is actually the cause.

@denyskon
Copy link
Member

I have the issue too, and I think I now found out when it happens. Basically, when a repo action like update issue label is being executed, the notify method

func notify(ctx context.Context, input *notifyInput) error {

is being triggered, which updates all the scheduled runs. But some actions like assignment of a label to an issue don't have a ref_name because they belong to the whole repo. For normal workflow triggers, the ref falls back to the default branch
ref = input.Repo.DefaultBranch

which is then also passed to the handleWorkflows method
return handleWorkflows(ctx, detectedWorkflows, commit, input, ref)

but not to the handleSchedules method
if err := handleSchedules(ctx, schedules, commit, input); err != nil {

So the simple fix should be also to pass the ref parameter to the handleSchedules method to use as action schedule ref.

PR incoming :)

@denyskon denyskon added the issue/confirmed Issue has been reviewed and confirmed to be present or accepted to be implemented label Dec 28, 2023
@denyskon denyskon added this to the 1.21.4 milestone Dec 28, 2023
lunny pushed a commit that referenced this issue Dec 29, 2023
GiteaBot pushed a commit to GiteaBot/gitea that referenced this issue Dec 29, 2023
lunny pushed a commit that referenced this issue Dec 29, 2023
Backport #28640 by @denyskon

Fix #27678 
Please see
#27678 (comment)
for details.

Co-authored-by: Denys Konovalov <kontakt@denyskon.de>
@wxiaoguang wxiaoguang added backport/v1.21 This PR should be backported to Gitea 1.21 and removed backport/v1.21 This PR should be backported to Gitea 1.21 labels Jan 2, 2024
fuxiaohei pushed a commit to fuxiaohei/gitea that referenced this issue Jan 17, 2024
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 17, 2024
silverwind pushed a commit to silverwind/gitea that referenced this issue Feb 20, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
issue/confirmed Issue has been reviewed and confirmed to be present or accepted to be implemented topic/gitea-actions related to the actions of Gitea type/bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants