API to generate runners token?

It would be very useful to have an api endpoint that would allow me to generate setup tokens for self-hosted Actions Runners dynamically and allow me to have packerized AMIs that automagically pull the token and connect to github. The inability to do this currently drastically limits their usefulness for me.

11 Likes

There is no Github API to generate tokens. When you want to setup self-hosted runner, you can go to repo Settings > Actions > Self-hosted runners section, clicking on “Add runner” button. Then there is a token for you to use in Configure steps.

For more information of Adding self-hosted runners, please refer to https://help.github.com/cn/actions/automating-your-workflow-with-github-actions/adding-self-hosted-runners

I know there isn’t an api. That’s why I said it would be useful to have one.

2 Likes

Sorry to tell you that as a security precaution, Github doesn’t provide an API to create personal access token. You need to follow the steps to create a PAT through web site.   https://help.github.com/en/github/authenticating-to-github/creating-a-personal-access-token-for-the-command-line

So a normal PAT can be used for this purpose of registering a self hosted action runner? Does it need any specific permissions in order to do this?

I don’t entirely understand how allowing api access to retrieve a token would be less secure than, say, using api access to interact with branches and repos and pull requests. There are already authenticated endpoints that plenty of automation users leverage.

1 Like

I’ve confirmed that PAT tokens cannot currently be used for this purpose, only the tokens obtained via Actions > Add Runner work. Which is a bit of a problem for us as they appear to be short lived.

2 Likes

An API for this is on the roadmap. I don’t have a timeline to share at the moment. But we’ll be posting to the Changelog when this is available.

And to clear up some of the confusion around PATs/runner tokens. The runner token provided via the UI is a temporary token that expires after 60 minutes. It only has the ability to register runners.

PATs are not able to register runners.

13 Likes

Perfect, good to know. Thanks!

Good to hear there will be an api to generate these tokens. We are trying to have self hosted action runners in aws fargate and so short lived tokens present a problem as the the runner tasks are transient. Also it would be benefitial to be able to scale them up and down as and when needed. Without the token api (or much longer lived tokens) this currently isn’t possible.

4 Likes

Also looking forward to this feature. I was also looking to provision short lived runners, but cannot easily without the token generation API.

Hey guys,

glad to here there is an API on the roadmap. Is there any ETA, so I know when about I can make the provisioning fully automated?

Thanks guys,

Michael

5 Likes

I asked GitHub support for an ETA, should be sometime next week. \o/

2 Likes

The GitHub Actions API has shipped https://developer.github.com/v3/actions/self_hosted_runners/

7 Likes

The generated self-hosted using API, is 130 characters long, way longer then the one generated on

"Settings -> Action -> Add runner ", doesn’t seems to work either, any ideas why?