Skip to content

Use GitHub application credentials to programmatically generate GitHub Actions Self Hosted Runner registration tokens

License

Notifications You must be signed in to change notification settings

davecozz/golang-github-enterprise-runners

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 

Repository files navigation

golang-github-enterprise-runners

So, you want to automatically register GitHub Actions Self Hosted Runners for your Orginizatiton. You've probably looked at the docs and thought "why did they make it so difficult?" Well, here's a fully working proof-of-concept using Go that will generate the various tokens and use them to call the APIs needed to (finally) get a Runner registration token.

!!! NOTE !!!

This code logs secret values and should NOT be used in a production environment! It is provided as a proof-of-concept so you can see the various steps needed to get a registration token. Also, the error handling and whole structure needs work before it's used for production workloads.

Prerequisites

  1. You've created a GitHub application and given it Read & Write permissions for Organization > Self-hosted runners.
  2. You've installed the app to the orginization for which you want to manage runners.
  3. You've generated a private key for the app and have a copy of the file.
  4. You've noted the App ID and its Installation ID.

Now you can update the const values in the main.go file and run it to get your runner registration tokens.

go run main.go

You can then use the token generated to register a new Runner.

./config.sh --url https://my.github-enterprise.com/MyOrg --token TOKEN

About

Use GitHub application credentials to programmatically generate GitHub Actions Self Hosted Runner registration tokens

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Languages