58 lines
1.9 KiB
YAML
58 lines
1.9 KiB
YAML
name: Manage AutoDL GPU runner
|
|
|
|
on:
|
|
workflow_dispatch:
|
|
inputs:
|
|
operation:
|
|
description: discover, provision, status, or shutdown
|
|
required: true
|
|
default: discover
|
|
image_uuid:
|
|
description: Required only for provision
|
|
required: false
|
|
default: ""
|
|
confirm_spend:
|
|
description: Type CREATE to provision a billed instance
|
|
required: false
|
|
default: ""
|
|
|
|
jobs:
|
|
manage:
|
|
runs-on: ces-control
|
|
timeout-minutes: 180
|
|
env:
|
|
AUTODL_API_TOKEN: ${{ secrets.AUTODL_API_TOKEN }}
|
|
TRAINING_RUNNER_REGISTRATION_TOKEN: ${{ secrets.TRAINING_RUNNER_REGISTRATION_TOKEN }}
|
|
GITEA_JOB_TOKEN: ${{ secrets.GITEA_TOKEN }}
|
|
OPERATION: ${{ inputs.operation }}
|
|
IMAGE_UUID: ${{ inputs.image_uuid }}
|
|
CONFIRM_SPEND: ${{ inputs.confirm_spend }}
|
|
steps:
|
|
- name: Checkout controller source
|
|
run: |
|
|
git init .
|
|
git remote add origin "$GITHUB_SERVER_URL/$GITHUB_REPOSITORY.git"
|
|
git -c http.extraHeader="Authorization: token $GITEA_JOB_TOKEN" fetch --depth 1 origin "$GITHUB_SHA"
|
|
git checkout --detach FETCH_HEAD
|
|
|
|
- name: Validate requested operation
|
|
run: |
|
|
case "$OPERATION" in
|
|
discover|provision|status|shutdown) ;;
|
|
*) echo "Unsupported operation" >&2; exit 2 ;;
|
|
esac
|
|
|
|
- name: Manage AutoDL Pro instance
|
|
run: |
|
|
python3 controller.py "$OPERATION" \
|
|
--image-uuid "$IMAGE_UUID" \
|
|
--confirm-spend "$CONFIRM_SPEND"
|
|
|
|
- name: Controller host details
|
|
if: always()
|
|
run: |
|
|
echo "host=$(hostname)"
|
|
date -Iseconds
|
|
test -f /root/.local/state/ces-autodl-controller/state.json && \
|
|
python3 -c 'import json; p="/root/.local/state/ces-autodl-controller/state.json"; d=json.load(open(p)); d.pop("root_password", None); print(json.dumps(d, indent=2))' || true
|