22
33set -e -u
44
5-
6- # first import docker image
7- if [ -f ./manywheel-ppc64le.tar ] ; then
8- docker image load --input manywheel-ppc64le.tar
9- docker image tag docker.io/pytorch/manylinuxppc64le-builder:cpu-ppc64le docker.io/pytorch/manylinuxsppc64le-builder:cpu-ppc64le-main
10- rm -f manywheel-ppc64le.tar
5+ # Fetch GitHub access token
6+ if [ ! -f /run/runner_secret ]; then
7+ echo " Error: Access token file not found at /run/runner_secret."
8+ exit 1
119fi
1210
1311token_file=registration-token.json
@@ -28,7 +26,6 @@ unset ACCESS_TOKEN
2826# it does one job, stops and unregisters
2927registration_token=$( jq --raw-output .token " $token_file " )
3028
31- cd /opt/runner
3229
3330./config.sh \
3431 --unattended \
@@ -50,11 +47,23 @@ rm -f "$token_file"
5047# Run one job.
5148./run.sh
5249
53- # Unregister runner after completion
54- ACCESS_TOKEN=" $( cat /run/runner_secret) "
55- curl \
56- -X DELETE \
50+ # Unregister runner after job completion
51+ echo " Unregistering runner from GitHub..."
52+ runner_id=$( curl -s \
5753 -H " Accept: application/vnd.github.v3+json" \
58- -H " Authorization: Bearer ${ACCESS_TOKEN} " \
59- " https://api.github.com/repos/${OWNER} /${REPO} /actions/runners/$( jq --raw-output .id < runner-id.json) "
60- unset ACCESS_TOKEN
54+ -H " Authorization: Bearer $( cat /run/runner_secret) " \
55+ " https://api.github.com/repos/${OWNER} /${REPO} /actions/runners" | \
56+ jq --raw-output ' .runners[] | select(.name=="' " ${NAME} " ' ") | .id' )
57+
58+ if [ -n " $runner_id " ]; then
59+ curl -s \
60+ -X DELETE \
61+ -H " Accept: application/vnd.github.v3+json" \
62+ -H " Authorization: Bearer $( cat /run/runner_secret) " \
63+ " https://api.github.com/repos/${OWNER} /${REPO} /actions/runners/$runner_id "
64+ echo " Runner unregistered successfully."
65+ else
66+ echo " Warning: Runner ID for ${NAME} not found. It may already be removed."
67+ fi
68+
69+ echo " Ephemeral runner workflow completed."
0 commit comments