mirror of
https://github.com/go-gitea/gitea.git
synced 2026-07-17 06:32:41 -05:00
actions: login via GITEA_TOKEN to package repository not working #10484
Open
opened 2025-11-02 09:08:51 -06:00 by GiteaMirror
·
39 comments
No Branch/Tag Specified
main
release/v1.25
release/v1.24
release/v1.23
release/v1.22
release/v1.21
release/v1.20
release/v1.19
release/v1.18
release/v1.17
release/v1.16
release/v1.15
release/v1.14
release/v1.13
release/v1.12
release/v1.11
release/v1.10
release/v1.9
release/v1.8
v1.25.3
v1.25.2
v1.25.1
v1.25.0
v1.24.7
v1.25.0-rc0
v1.26.0-dev
v1.24.6
v1.24.5
v1.24.4
v1.24.3
v1.24.2
v1.24.1
v1.24.0
v1.23.8
v1.24.0-rc0
v1.25.0-dev
v1.23.7
v1.23.6
v1.23.5
v1.23.4
v1.23.3
v1.23.2
v1.23.1
v1.23.0
v1.23.0-rc0
v1.24.0-dev
v1.22.6
v1.22.5
v1.22.4
v1.22.3
v1.22.2
v1.22.1
v1.22.0
v1.23.0-dev
v1.22.0-rc1
v1.21.11
v1.22.0-rc0
v1.21.10
v1.21.9
v1.21.8
v1.21.7
v1.21.6
v1.21.5
v1.21.4
v1.21.3
v1.21.2
v1.20.6
v1.21.1
v1.21.0
v1.21.0-rc2
v1.21.0-rc1
v1.20.5
v1.22.0-dev
v1.21.0-rc0
v1.20.4
v1.20.3
v1.20.2
v1.20.1
v1.20.0
v1.19.4
v1.21.0-dev
v1.20.0-rc2
v1.20.0-rc1
v1.20.0-rc0
v1.19.3
v1.19.2
v1.19.1
v1.19.0
v1.19.0-rc1
v1.20.0-dev
v1.19.0-rc0
v1.18.5
v1.18.4
v1.18.3
v1.18.2
v1.18.1
v1.18.0
v1.17.4
v1.18.0-rc1
v1.19.0-dev
v1.18.0-rc0
v1.17.3
v1.17.2
v1.17.1
v1.17.0
v1.17.0-rc2
v1.16.9
v1.17.0-rc1
v1.18.0-dev
v1.16.8
v1.16.7
v1.16.6
v1.16.5
v1.16.4
v1.16.3
v1.16.2
v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.4.0-rc1
v1.3.2
v1.3.1
v1.3.0
v1.3.0-rc2
v1.3.0-rc1
v1.2.3
v1.2.2
v1.2.1
v1.2.0
v1.2.0-rc3
v1.2.0-rc2
v1.1.4
v1.2.0-rc1
v1.1.3
v1.1.2
v1.1.1
v1.1.0
v1.0.2
v1.0.1
v1.0.0
v0.9.99
Labels
Clear labels
$20
$250
$50
$500
backport/done
💎 Bounty
docs-update-needed
good first issue
hacktoberfest
issue/bounty
issue/confirmed
issue/critical
issue/duplicate
issue/needs-feedback
issue/not-a-bug
issue/regression
issue/stale
issue/workaround
lgtm/need 2
modifies/api
modifies/translation
outdated/backport/v1.18
outdated/theme/markdown
outdated/theme/timetracker
performance/bigrepo
performance/cpu
performance/memory
performance/speed
pr/breaking
proposal/accepted
proposal/rejected
pr/wip
pull-request
reviewed/wontfix
💰 Rewarded
skip-changelog
status/blocked
topic/accessibility
topic/api
topic/authentication
topic/build
topic/code-linting
topic/commit-signing
topic/content-rendering
topic/deployment
topic/distribution
topic/federation
topic/gitea-actions
topic/issues
topic/lfs
topic/mobile
topic/moderation
topic/packages
topic/pr
topic/projects
topic/repo
topic/repo-migration
topic/security
topic/theme
topic/ui
topic/ui-interaction
topic/ux
topic/webhooks
topic/wiki
type/bug
type/deprecation
type/docs
type/enhancement
type/feature
type/miscellaneous
type/proposal
type/question
type/refactoring
type/summary
type/testing
type/upstream
Mirrored from GitHub Pull Request
Milestone
No items
No Milestone
Projects
Clear projects
No project
No Assignees
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: github-starred/gitea#10484
Reference in New Issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @krombel on GitHub (Mar 22, 2023).
Description
I am having this snippet in a workflow file:
I exchanged
github.repository_ownerwithgithub.actoras well. Bot did not work.I see the following error in the actions run log:
Gitea Version
1.19.0
Can you reproduce the bug on the Gitea demo site?
No
Log Gist
No response
Screenshots
No response
Git Version
No response
Operating System
No response
How are you running Gitea?
I am running it in a docker container and am reverse proxying the https port.
Database
None
@dboreham commented on GitHub (Mar 22, 2023):
Token scope was added in 1.19 so perhaps your token needs to be re-issued with a new scope (this happened to me in a slightly different context but where I could see the full error response from gitea which mentioned the token scope being inadequate).
@lunny commented on GitHub (Mar 23, 2023):
Did you set your ROOT_RUL in app.ini to
my.gitea.domain?@krombel commented on GitHub (Mar 23, 2023):
@dboreham How do you do that? As far as I understood that specific token is a task defined token which would not affect any secrets I have defined myself.
be93e48ccb/routers/api/actions/runner/utils.go (L70)I think there is a typo 😉 . I set ROOT_URL at least to
https://my.gitea.domain@KN4CK3R commented on GitHub (Mar 23, 2023):
Does it work from the command line?
docker login -u ... -p token my.gitea.domain@krombel commented on GitHub (Mar 23, 2023):
The package repository itself is working. When I try to use a pregenerated secret and use that, it is working as well.
What is not working ist the use of the GITEA_TOKEN to publish data into the package repository.
@yp05327 commented on GitHub (Mar 24, 2023):
401 Unauthorized is returned by
ReqContainerAccess(defined in routers/api/packages/container/container.go)I removed

container.ReqContainerAccesshere, it returns success.(not a fix, just a test)d02e83a2c3/routers/api/packages/api.go (L460)@KN4CK3R commented on GitHub (Mar 24, 2023):
Just a note: That looks like it works but you can't upload a container or other things.
@philkunz commented on GitHub (Jun 26, 2023):
What is the status on this one?
@lunny commented on GitHub (Jun 26, 2023):
It depends on the trigger user's permission to that package. And you can always use a PAT to do that.
@philkunz commented on GitHub (Jun 26, 2023):
Ok, but 1.19.3 still does not pay respect to that, or? Because the build happens on push through me, I'm the owner of the repo and it still fails with authentication required after using GITEA_TOKEN for a successful Docker Login.
Which is the earliest version that works?
@KN4CK3R commented on GitHub (Jun 26, 2023):
The linked PR is active with 1.20
@AndyTempel commented on GitHub (Jul 2, 2023):
Currently on 1.20.0-rc2 and this works:
But push fails with:
docker/build-push-action@2eb1c1961a95fc15694676618e422e8ba1d63825@krombel commented on GitHub (Jul 3, 2023):
That is right as @KN4CK3R mentioned before: https://github.com/go-gitea/gitea/issues/23642#issuecomment-1482584036
Here it got decided to temporarily only allow read only access and postpone the permission check: https://github.com/go-gitea/gitea/pull/23729#issuecomment-1492774010
The underlining issue is an ongoing discussion how to manage permissions in general. There is a proposal in https://github.com/go-gitea/gitea/issues/24635 but nothing implemented in that direction yet (AFAIK)
@sgabenov commented on GitHub (Sep 18, 2023):
You can try to specify token within url
@PatrickHuetter commented on GitHub (Sep 29, 2023):
Same result for me with gitea 1.20.4. How do you push the docker images to the gitea container registry from within the gitea actions? Do you use custom PATs instead the GITEA_TOKEN/GITHUB_TOKEN?
@krombel commented on GitHub (Sep 29, 2023):
@PatrickHuetter You must use PATs for writing to package repositories right now.
As mentioned in my comment before there is no implementation yet - not in master and therefore in no release either - to use GIT{EA,HUB}_TOKEN for pushing to package repositories.
@PatrickHuetter commented on GitHub (Sep 29, 2023):
Thanks @krombel. I got it working with PATs.
@the-maldridge commented on GitHub (Mar 1, 2024):
This should be listed as a missing feature on this page. My organization does not permit static PATs to be used in workflows, which means we can't use that as a workaround. It would have been much easier to figure out this is why the permissions error occurs if it had been listed in the documentation as a current limitation.
@Elbandi commented on GitHub (Apr 6, 2024):
it doesnt work for me with user PAT:
i added some debug logs:
So looks like container.Verify() found the right user, but doesnt fill the IsApiToken and ApiTokenScope data fields. therefore reqPackageAccess denied the access.
Gitea version: 1.21.10 built with GNU Make 4.2.1, go1.21.9 : bindata, sqlite, sqlite_unlock_notify
@lunny commented on GitHub (Apr 7, 2024):
I cannot reproduce this. Please check your PAT's permission which has read/write packages permission.
@Elbandi commented on GitHub (Apr 7, 2024):
scope: all, and "jenkins" user is added to project with write permission.
(ofc just for testing)
@lunny commented on GitHub (Apr 8, 2024):
You still need to choose the permissions after choosing ALL in the UI. ALL means all of the repositories which don't mean permissions.
@Elbandi commented on GitHub (Apr 10, 2024):
As i said, all permissions are added. i listed the tokes by api:
Response:
@yp05327 commented on GitHub (Apr 11, 2024):
If the owner of this repo is organization, does this user have the permission to access organization packages?
@KN4CK3R commented on GitHub (May 14, 2024):
I don't think this is implemented. The job token can't be used to publish packages at the moment.
@Elbandi commented on GitHub (May 18, 2024):
It look like, token is not working for personal repo (eg: elbandi/test)
Here, i create a new token for jenkins user with full access:
I verify, that jenkins user has write permission to elbandi/test:
result (look good: jenkins has write role to elbandi/test):
Try to upload a file as a generic package to elbandi/test:
unsuccessful :(
Try to upload a file as a generic package to an organisation package:
it works.
@chrisliebaer commented on GitHub (May 20, 2024):
Sadly, this issue covers quite an important feature, but the discussion has been dissolved by unrelated topics of improper configuration.
As highlighted by others, at the very least, a note should be placed here: https://docs.gitea.com/usage/actions/comparison#missing-features I just spent 2 hours assuming that Gitea would support this feature, as it's very common and not listed.
Creating a PAT does not solve this issue. A PAT can not be scoped to a single repo, has to be created manually, and managed / copied / or stored (unless we want to end up with multiple PATs)
Gitea already associates packages with repos, so mirroring GitHubs should probably be supported without changes to Giteas design.
The basic flow should probably be something like this:
${{ github.repository_owner }}namespace${{ github.repository_owner }}packages and associated with repoThis also means that if UserB pushes changes to a repo owned by UserA, the token will have access to the UserA package namespace.
Now I don't have any idea what your goals and concerns are, but PATs should be seen as a workaround, not as a solution, since they are clumsy, error-prone and give access to the namespace of the owner.
@philkunz commented on GitHub (May 24, 2024):
@lunny What would be the right way of getting this going?
@lunny commented on GitHub (May 25, 2024):
Create a PAT with permission of package and use that PAT to do login, push.
@alex3305 commented on GitHub (Jul 27, 2024):
As a temporary workaround I have defined an
actionsuser which I gave sufficient rights on the repositories that I want to use actions with. Or in my case I've made this an admin user which cannot login through the web UI. The latter I disabled as a final step.For this user I created a PAT
and set that up as a secret variable on the Actions > Secrets page on the user's profile asAppearently I still have to set that PAT on my own profile as well. Otherwise the secret cannot be found. I can than use a pretty similar approach to the intended one:PACKAGES_TOKENso I can use that variable within my Actions.Note that I also defined my registry and actions user in my runner's
config.yaml:This seems to work perfectly. Or at least for the time being 😄 .
Instead of using a dedicated user you could also opt to set your own username as the
actions_userand add the PAT to your Actions > Secrets in your profile.@jonas-switala commented on GitHub (Oct 3, 2024):
I'm curious how you got that to work?
While creating a separate 'actions_user' with a PAT and write access to packages works for me to publish packages for my organization (by setting PACKAGES_TOKEN as a secret at the organization level), I have observed that it is not possible to disable login for that user after creating the PAT, since this does not only prohibit login to the web UI but also to the packages registry using the PAT.
In contrast to you I'm testing with the PyPi repo and my 'actions_user' doesn't have admin permissions but write acces to all repos in the organization. I don't think this should make a difference though.
@jbalonso commented on GitHub (Oct 7, 2024):
I have filed a PR here: https://gitea.com/gitea/docs/pulls/77.
@minionflo commented on GitHub (Apr 13, 2025):
any updates on this?
@omnicortex commented on GitHub (Jun 18, 2025):
any progress?
@lunny commented on GitHub (Jun 18, 2025):
Maybe it should be allowed to login and operate the repository related package. But it cannot pushing new package or visit the packages which is unrelated to the repository the actions running.
@marvint24 commented on GitHub (Jun 18, 2025):
I think it would be an improvement, but it would not be straight forward. Because if I understand you correctly you would always need to upload a package initially and link it before a pipeline could update it.
I am currently using a separate token for private repos and a separate user and token for organizations and this approach works quite well for me. Maybe a solution could be to automatically set a secret (e.g. RUNNER_TOKEN) that could be used in pipelines to access the packages.
@idchlife commented on GitHub (Aug 28, 2025):
So, would I be correct in saying that the GITEA token authentication currently does not work, and PAT should be used instead as a workaround?
@lunny commented on GitHub (Aug 28, 2025):
Yes, the permission of
GITEA_TOKENis limited by design becausepermissionshaven't been implemented. At the moment, aPATis necessary to publish package.@Frankkkkk commented on GitHub (Aug 29, 2025):
And for those who are interested, there's a 220$ bounty in making it work (related issue #24635; I guess it replaces this one?) :-).