-
Notifications
You must be signed in to change notification settings - Fork 4
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
feat: support for self-hosted runners at organization level #11
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for your PR @vprashar2929 ! 🚀
This will be helpful. However, it is possible that even in an org, you may want or need to register a self-runner at repo level. Could you please add an input for that?
Something like:
repository_level:
description: 'Set to true to use repository-level registration token'
required: false
default: false
And then the condition would be:
if [[ "${{ inputs.repository_level }}" == "true" ]] || [[ -z "${{ github.organization }}" ]]; then
url="https://api.github.com/repos/${{ github.repository }}/actions/runners/registration-token"
else
url="https://api.github.com/orgs/${{ github.organization }}/actions/runners/registration-token"
fi
@ocobles Updated the PR 😄 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@vprashar2929 I realized that we will need some more changes. Where it says sudo -E -u ghrunner ./config.sh
... the url must be updated too. Here's a suggestion:
register a runner-scope variable
if [[ "${{ inputs.repository_level }}" == "true" ]] || [[ -z "${{ github.organization }}" ]]; then
runner_scope="${{ github.repository }}"
url="https://api.github.com/repos/${{ runner_scope }}/actions/runners/registration-token"
else
runner_scope="${{ github.organization }}"
url="https://api.github.com/orgs/${{ runner_scope }}/actions/runners/registration-token"
fi
token=$(curl -fsSL \
-X POST \
-H 'accept: application/vnd.github+json' \
-H 'authorization: Bearer ${{ inputs.github_token }}' \
-H 'X-GitHub-Api-Version: 2022-11-28' \
--url $url | jq -r .token)
echo "registration-token=${token}" >> $GITHUB_OUTPUT
echo "runner-scope=${runner_scope}" >> $GITHUB_OUTPUT
and in the Create Device
step update the url and labels args:
sudo -E -u ghrunner ./config.sh --unattended --url https://github.com/${{ steps.get-registration-token.outputs.runner-scope }} --token ${{ steps.get-registration-token.outputs.registration-token }} --name $(hostname) --work /home/ghrunner --labels ${{ steps.get-registration-token.outputs.runner-scope }} --ephemeral
This commit introduces the ability to register self-hosted runners using both organization and repository level registration tokens. Signed-off-by: Vibhu Prashar <vibhu.sharma2929@gmail.com>
My bad I forgot to check that. 😞 Fixed now |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍🏼 looks good!
This commit introduces the ability to register self-hosted runners using both organization and repository level registration tokens.
Fixes #10