added github_actions_runner.sh

pull/2/head
Hari Sekhon 3 years ago
parent e147dfc8a2
commit 9a0ab0c324

@ -0,0 +1,44 @@
#!/usr/bin/env bash
# vim:ts=4:sts=4:sw=4:et
#
# Author: Hari Sekhon
# Date: 2021-11-05 04:25:16 +0000 (Fri, 05 Nov 2021)
#
# https://github.com/harisekhon/bash-tools
#
# License: see accompanying Hari Sekhon LICENSE file
#
# If you're using my code you're welcome to connect with me on LinkedIn and optionally send me feedback to help steer this or other code I publish
#
# https://www.linkedin.com/in/harisekhon
#
set -euo pipefail
[ -n "${DEBUG:-}" ] && set -x
srcdir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
# shellcheck source=lib/utils.sh
. "$srcdir/lib/utils.sh"
# shellcheck disable=SC2034,SC2154
usage_description="
Generates a GitHub Actions Runner token for the given Repo or Organization via the GitHub API and then run a Dockerized GitHub Actions runner with the appropriate configuration
"
# used by usage() in lib/utils.sh
# shellcheck disable=SC2034
usage_args="<repo_or_organization>"
help_usage "$@"
min_args 1 "$@"
repo_or_org="$1"
if [[ "$repo_or_org" =~ / ]]; then
token="$("$srcdir/github_api.sh" "/repos/$repo_or_org/actions/runners/registration-token" -X POST | jq -r '.token')"
else # it's an org
token="$("$srcdir/github_api.sh" "/orgs/$repo_or_org/actions/runners/registration-token" -X POST | jq -r '.token')"
fi
docker run -ti harisekhon/github-actions-runner --url "https://github.com/$repo_or_org" --token "$token" --unattended
Loading…
Cancel
Save