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

sync should check if it has repo permissions first. #15

Open
jamielennox opened this issue Feb 9, 2021 · 2 comments
Open

sync should check if it has repo permissions first. #15

jamielennox opened this issue Feb 9, 2021 · 2 comments
Labels
enhancement New feature or request stale

Comments

@jamielennox
Copy link

We run actions-sync with a service account, the account has permissions on the main actions repo but we also use it for syncing actions for teams.

What we tried to do is have someone on the team create the empty repo in the desired org, provide the service account write access to the repo and then run sync. However this fails with messages like:

error creating github repository `XXX/YYY`: error creating repository XXX/YYY: POST https://org/api/v3/orgs/XXX/repos: 403 You need admin access to the organization before adding a repository to it. []
##[error]Process completed with exit code 1.

Because the logic is trying to use that token to query if the repo exists via the github api, which it doesn't have permissions to do.

To reduce the permissions needed here the first check should really be direct to the repo to see if we can simply use it rather than have to check and create it.

@ajaykn
Copy link
Contributor

ajaykn commented Feb 16, 2021

Thanks @jamielennox
Yeah currently tool tries to create the repo and if it exists then we fetch it.
I agree, we need to first fetch the repo and if it not exists then try creating it.

https://github.com/actions/actions-sync/blob/main/src/push.go#L149-L154

        ghRepo, resp, err := client.Repositories.Create(ctx, createRepoOrgName, repo)
	if err == nil {
		fmt.Printf("Created repo `%s/%s`\n", ownerName, repoName)
	} else if resp != nil && resp.StatusCode == 422 {
		ghRepo, _, err = client.Repositories.Get(ctx, ownerName, repoName)
	}

We have added this to our backlog and will prioritize it accordingly.

@ajaykn ajaykn added the enhancement New feature or request label Feb 16, 2021
Copy link

This issue is stale because it has been open for 30 days with no activity.

@github-actions github-actions bot added the stale label Apr 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request stale
Projects
None yet
Development

No branches or pull requests

2 participants