Skip to content

Commit 94cad81

Browse files
set the work dir
1 parent b4dbab3 commit 94cad81

File tree

1 file changed

+23
-14
lines changed

1 file changed

+23
-14
lines changed

.github/scripts/ppc64le/self-hosted-builder/fs/usr/bin/actions-runner

Lines changed: 23 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,10 @@
22

33
set -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
119
fi
1210

1311
token_file=registration-token.json
@@ -28,7 +26,6 @@ unset ACCESS_TOKEN
2826
# it does one job, stops and unregisters
2927
registration_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

Comments
 (0)