Home > Software design >  How to give write permission to a team for a repository using Octokit/GitHub API?
How to give write permission to a team for a repository using Octokit/GitHub API?

Time:07-29

I'm using JavaScript and Octokit to dynamically create repositories in an organization and set a series of options.

Everything works, except adding write permissions to a team for the repository created.

Just to be clear, by write permission I mean the ones that can be set through the repository settings:

Settings > Collaborators and teams > Manage Acccess > Role: Write

What I've been trying to use so far, was the octokit.rest.teams.addOrUpdateRepoPermissionsInOrg function in Octokit, documented here, like this:

octokit.rest.teams.addOrUpdateRepoPermissionsInOrg({
  org: "org-name",
  team_slug: "team-name",
  owner: "owner-name",
  repo: "repo-name",
  permission: "write",
}

When doing this, I receive a Validation Failed error.

Checking the relative documentation on the GitHub API docs, it effectively seems that the valid values for permission are: pull, push, admin, maintain, triage

So I guess that I'm simply using the wrong function.

But what's the correct one to change that kind of permission?

CodePudding user response:

I managed to make it work: apparently, the push permission in the API corresponds to the write permission in the GitHub web interface.

FYI: this seems like a discrepancy, so I opened an issue.

  • Related