|
| 1 | +name: 'Launch GPU EC2 Runner' |
| 2 | +description: 'Launch GPU-enabled EC2 instance as GitHub Actions self-hosted runner (wrapper for machulav/ec2-github-runner)' |
| 3 | + |
| 4 | +on: |
| 5 | + workflow_dispatch: |
| 6 | +inputs: |
| 7 | + mode: |
| 8 | + description: 'Mode: start or stop' |
| 9 | + required: true |
| 10 | + github-token: |
| 11 | + description: 'GitHub Personal Access Token with repo scope for runner registration' |
| 12 | + required: true |
| 13 | + instance-type: |
| 14 | + description: 'EC2 instance type (e.g., g6.2xlarge, g5.2xlarge, g6.8xlarge)' |
| 15 | + required: false |
| 16 | + default: 'g6.2xlarge' |
| 17 | + aws-region: |
| 18 | + description: 'AWS region' |
| 19 | + required: true |
| 20 | + availability-zones-config: |
| 21 | + description: 'JSON array of AZ configs with imageId, subnetId, securityGroupId for fallback' |
| 22 | + required: false |
| 23 | + default: '' |
| 24 | + # For stop mode |
| 25 | + label: |
| 26 | + description: 'Runner label (for stop mode)' |
| 27 | + required: false |
| 28 | + ec2-instance-id: |
| 29 | + description: 'EC2 instance ID (for stop mode)' |
| 30 | + required: false |
| 31 | + # Optional |
| 32 | + ec2-instance-tags: |
| 33 | + description: 'JSON array of tags to apply to EC2 instance' |
| 34 | + required: false |
| 35 | + default: '[]' |
| 36 | + runner-home-dir: |
| 37 | + description: 'Home directory for the runner' |
| 38 | + required: false |
| 39 | + default: '' |
| 40 | + iam-role-name: |
| 41 | + description: 'IAM role name to attach to the instance (optional, for enhanced security)' |
| 42 | + required: false |
| 43 | + default: '' |
| 44 | + |
| 45 | +outputs: |
| 46 | + label: |
| 47 | + description: 'Unique label for the launched runner' |
| 48 | + value: ${{ steps.ec2-runner.outputs.label }} |
| 49 | + ec2-instance-id: |
| 50 | + description: 'EC2 instance ID' |
| 51 | + value: ${{ steps.ec2-runner.outputs.ec2-instance-id }} |
| 52 | + |
| 53 | +runs: |
| 54 | + using: 'composite' |
| 55 | + steps: |
| 56 | + - name: Start EC2 runner |
| 57 | + if: inputs.mode == 'start' |
| 58 | + id: ec2-runner |
| 59 | + uses: machulav/ec2-github-runner@343a1b2ae682e681c3cec9a235d882da17ff04ef # v2.6.1 |
| 60 | + env: |
| 61 | + AWS_DEFAULT_REGION: ${{ inputs.aws-region }} |
| 62 | + AWS_REGION: ${{ inputs.aws-region }} |
| 63 | + with: |
| 64 | + mode: start |
| 65 | + github-token: ${{ inputs.github-token }} |
| 66 | + ec2-instance-type: ${{ inputs.instance-type }} |
| 67 | + aws-resource-tags: ${{ inputs.ec2-instance-tags }} |
| 68 | + runner-home-dir: ${{ inputs.runner-home-dir }} |
| 69 | + iam-role-name: ${{ inputs.iam-role-name }} |
| 70 | + availability-zones-config: ${{ inputs.availability-zones-config }} |
| 71 | + |
| 72 | + - name: Stop EC2 runner |
| 73 | + if: inputs.mode == 'stop' |
| 74 | + uses: machulav/ec2-github-runner@343a1b2ae682e681c3cec9a235d882da17ff04ef # v2.6.1 |
| 75 | + env: |
| 76 | + AWS_DEFAULT_REGION: ${{ inputs.aws-region }} |
| 77 | + AWS_REGION: ${{ inputs.aws-region }} |
| 78 | + with: |
| 79 | + mode: stop |
| 80 | + github-token: ${{ inputs.github-token }} |
| 81 | + label: ${{ inputs.label }} |
| 82 | + ec2-instance-id: ${{ inputs.ec2-instance-id }} |
0 commit comments