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

"Variable" set for gitea action not accessible in job #26309

Closed
bf opened this issue Aug 3, 2023 · 8 comments · Fixed by #26317
Closed

"Variable" set for gitea action not accessible in job #26309

bf opened this issue Aug 3, 2023 · 8 comments · Fixed by #26317
Labels
issue/not-a-bug The reported issue is the intended behavior or the problem is not inside Gitea type/docs This PR mainly updates/creates documentation

Comments

@bf
Copy link

bf commented Aug 3, 2023

Description

When setting a custom variable for gitea action in "repo -> settings -> actions -> variables -> "Variables Management"" it is not accessible in the job.

I have tried ${{VARNAME}}, ${{github.VARNAME}}, ${{env.VARNAME}}, and ${{gitea.VARNAME}}.

act_runner is on a different server.

Gitea Version

1.21.0+dev-437-gb9baed2c74

Can you reproduce the bug on the Gitea demo site?

Yes

Log Gist

No response

Screenshots

No response

Git Version

No response

Operating System

archlinux

How are you running Gitea?

installed gitea-git package from archlinux AUR

Database

SQLite

@bf bf added the type/bug label Aug 3, 2023
@bf
Copy link
Author

bf commented Aug 3, 2023

image

@bf
Copy link
Author

bf commented Aug 3, 2023

expression 'echo ${{secrets.DOCKER_PASSWORD}} | docker login --password-stdin --username ${{gitea.DOCKER_USERNAME}} myregistry.com' rewritten to 'format('echo {0} | docker login --password-stdin --username {1} myregistry.com', secrets.DOCKER_PASSWORD, gitea.DOCKER_USERNAME)'
evaluating expression 'format('echo {0} | docker login --password-stdin --username {1} myregistry.com', secrets.DOCKER_PASSWORD, gitea.DOCKER_USERNAME)'
expression 'format('echo {0} | docker login --password-stdin --username {1} myregistry.com', secrets.DOCKER_PASSWORD, gitea.DOCKER_USERNAME)' evaluated to '%!t(string=echo *** | docker login --password-stdin --username  myregistry.com)'

@bf
Copy link
Author

bf commented Aug 3, 2023

"secrets" work fine via ${{secrets.VARNAME}} but variables dont

@bf
Copy link
Author

bf commented Aug 3, 2023

${{variables.VARNAME}} doesn't work either:

Unable to interpolate expression 'format('echo {0} | docker login --password-stdin --username {1} myrepository.com', secrets.DOCKER_PASSWORD, variables.DOCKER_USERNAME)': Unavailable context: variables

@bf
Copy link
Author

bf commented Aug 3, 2023

I see gitea developers themselves use "secrets" to store the DOCKER_USERNAME, because it doesn't seem to work otherways. Why isn't there a disclaimer in "Variables Management" UI?

https://github.com/go-gitea/gitea/actions/runs/5328145644/workflow#L76

@bf
Copy link
Author

bf commented Aug 3, 2023

Finally found #24724

@sillyguodong can you please improve gitea documentation so that it is clear ${{vars.VARNAME}} needs to be used? It should be said both in the UI at org/reponame/settings/actions/variables and in the gitea docs.

@bf
Copy link
Author

bf commented Aug 3, 2023

Not sure why for "Variables" the abbreviation is ${{vars.VARNAME}} but for "Secrets" the abbreviation is ${{secrets.VARNAME}}. It should be the same style, either full or abbreviated.

@sillyguodong
Copy link
Contributor

Not sure why for "Variables" the abbreviation is ${{vars.VARNAME}}.

The workflow syntax of Gitea Actions is consistent with Github(see https://docs.github.com/en/actions/learn-github-actions/contexts#vars-context).

@sillyguodong can you please improve gitea documentation

Sure

@sillyguodong sillyguodong added issue/not-a-bug The reported issue is the intended behavior or the problem is not inside Gitea and removed type/bug labels Aug 4, 2023
@sillyguodong sillyguodong added the type/docs This PR mainly updates/creates documentation label Aug 4, 2023
lunny pushed a commit that referenced this issue Aug 4, 2023
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 19, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
issue/not-a-bug The reported issue is the intended behavior or the problem is not inside Gitea type/docs This PR mainly updates/creates documentation
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants