mirror of
https://github.com/actions/runner.git
synced 2025-12-18 00:07:08 +00:00
remove fixes
This commit is contained in:
@@ -128,5 +128,3 @@ echo
|
|||||||
echo "Configuring as a service ..."
|
echo "Configuring as a service ..."
|
||||||
./svc.sh install ${svc_user}
|
./svc.sh install ${svc_user}
|
||||||
./svc.sh start
|
./svc.sh start
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -26,36 +26,43 @@ runner_name=${2:-$(hostname)}
|
|||||||
echo "Uninstalling runner ${runner_name} @ ${runner_scope}"
|
echo "Uninstalling runner ${runner_name} @ ${runner_scope}"
|
||||||
sudo echo
|
sudo echo
|
||||||
|
|
||||||
|
function fatal()
|
||||||
|
{
|
||||||
|
echo "error: $1" >&2
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
|
if [ -z "${runner_scope}" ]; then fatal "supply scope as argument 1"; fi
|
||||||
|
if [ -z "${RUNNER_CFG_PAT}" ]; then fatal "RUNNER_CFG_PAT must be set before calling"; fi
|
||||||
|
|
||||||
#---------------------------------------
|
#---------------------------------------
|
||||||
# Stop and uninstall the service
|
# Stop and uninstall the service
|
||||||
#---------------------------------------
|
#---------------------------------------
|
||||||
echo
|
echo
|
||||||
echo "Uninstall the service ..."
|
echo "Uninstall the service ..."
|
||||||
|
pushd ./runner
|
||||||
./svc.sh stop
|
./svc.sh stop
|
||||||
./svc.sh uninstall
|
./svc.sh uninstall
|
||||||
|
|
||||||
#--------------------------------------
|
|
||||||
# Get a removal token
|
|
||||||
#--------------------------------------
|
|
||||||
echo
|
|
||||||
echo "Generating a removal registration token..."
|
|
||||||
|
|
||||||
# if the scope has a slash, it's an repo runner
|
|
||||||
base_api_url="https://api.github.com/orgs"
|
base_api_url="https://api.github.com/orgs"
|
||||||
if [[ "$runner_scope" == *\/* ]]; then
|
if [[ "$runner_scope" == *\/* ]]; then
|
||||||
base_api_url="https://api.github.com/repos"
|
base_api_url="https://api.github.com/repos"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
export REMOVE_TOKEN=$(curl -s -X POST ${base_api_url}/${runner_scope}/actions/runners/remove-token -H "accept: application/vnd.github.everest-preview+json" -H "authorization: token ${RUNNER_CFG_PAT}" | jq -r '.token')
|
#--------------------------------------
|
||||||
|
# Get id of runner to remove
|
||||||
|
#--------------------------------------
|
||||||
|
runner_id=$(curl -s -X GET ${base_api_url}/${runner_scope}/actions/runners -H "accept: application/vnd.github.everest-preview+json" -H "authorization: token ${RUNNER_CFG_PAT}" | jq -M -j ".runners | .[] | [select(.name == \"${runner_name}\")] | .[0].id")
|
||||||
|
|
||||||
if [ -z "$REMOVE_TOKEN" ]; then fatal "Failed to get a token"; fi
|
if [ -z "${runner_id}" ]; then
|
||||||
|
fatal "Could not find runner with name ${runner_name}"
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "Removing id ${runner_id}"
|
||||||
|
|
||||||
#--------------------------------------
|
#--------------------------------------
|
||||||
# Remove the runner
|
# Remove the runner
|
||||||
#--------------------------------------
|
#--------------------------------------
|
||||||
# DELETE /orgs/:organization/actions/runners/:runner_id
|
curl -s -X DELETE ${base_api_url}/${runner_scope}/actions/runners/${runner_id} -H "authorization: token ${RUNNER_CFG_PAT}"
|
||||||
curl -s -X DELETE ${base_api_url}/${runner_scope}/actions/runners/remove-token -H "authorization: token ${REMOVE_TOKEN}"
|
|
||||||
|
|
||||||
echo "Done."
|
echo "Done."
|
||||||
|
|||||||
Reference in New Issue
Block a user