|
| 1 | +jobs: |
| 2 | + start-runner: |
| 3 | + timeout-minutes: 5 # normally it only takes 1-2 minutes |
| 4 | + name: Start self-hosted EC2 runner |
| 5 | + runs-on: ubuntu-latest |
| 6 | + permissions: |
| 7 | + actions: write |
| 8 | + steps: |
| 9 | + - name: Start EC2 runner |
| 10 | + id: start-ec2-runner |
| 11 | + uses: NextChapterSoftware/ec2-action-builder@v1.10 |
| 12 | + with: |
| 13 | + aws_access_key_id: ${{ secrets.AWS_ACCESS_KEY_ID }} |
| 14 | + aws_secret_access_key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} |
| 15 | + aws_iam_role_arn: "arn:aws:iam::REDACTED:role/REDACTED" |
| 16 | + aws_region: "us-west-2" |
| 17 | + github_token: ${{ secrets.PERSONAL_ACCESS_TOKEN }} |
| 18 | + github_action_runner_version: v2.300.2 # Optional (default is latest release) |
| 19 | + github_action_runner_extra_cli_args: "--disableupdate" # Extra cli args for runner startup command |
| 20 | + github_job_start_ttl_seconds: 60 # Optional - (defaults to 0 disabling this feature) |
| 21 | + github_api_retry_delay: 10 # Optional - Delay when polling for runner registration (default is 10 seconds) |
| 22 | + ec2_instance_type: c5.4xlarge |
| 23 | + ec2_ami_id: ami-008fe2fc65df48dac |
| 24 | + ec2_root_disk_size_gb: "100" # Optional - (defaults to AMI settings) |
| 25 | + ec2_root_disk_ebs_class: "gp2" # Optional - Only used with custom volume root size (defaults to gp2) |
| 26 | + ec2_subnet_id: "SUBNET_ID_REDACTED" |
| 27 | + ec2_security_group_id: "SECURITY_GROUP_ID_REDACTED" |
| 28 | + ec2_instance_ttl: 40 # Optional - (default is 60 minutes) |
| 29 | + ec2_spot_instance_strategy: MaxPerformance # Other options are: None, BestEffort, MaxPerformance |
| 30 | + ec2_instance_tags: > # Required for IAM role resource permission scoping |
| 31 | + [ |
| 32 | + {"Key": "Owner", "Value": "deploybot"} |
| 33 | + ] |
| 34 | +
|
| 35 | + # Job that runs on the self-hosted runner |
| 36 | + run-build: |
| 37 | + timeout-minutes: 1 |
| 38 | + needs: |
| 39 | + - start-runner |
| 40 | + runs-on: ${{ github.run_id }} |
| 41 | + steps: |
| 42 | + - run: env |
| 43 | + |
| 44 | + - name: Verify EC2 Instance |
| 45 | + run: | |
| 46 | + echo "Checking instance information..." |
| 47 | + # Check if we're on EC2 |
| 48 | + TOKEN=$(curl -X PUT "http://169.254.169.254/latest/api/token" -H "X-aws-ec2-metadata-token-ttl-seconds: 21600") |
| 49 | + curl -H "X-aws-ec2-metadata-token: $TOKEN" http://169.254.169.254/latest/meta-data/instance-type |
| 50 | + |
| 51 | + echo "Checking system resources..." |
| 52 | + lscpu |
| 53 | + free -h |
| 54 | + df -h |
| 55 | + nvidia-smi # This will show GPU if available |
| 56 | + |
| 57 | + echo "Checking environment..." |
| 58 | + env | grep AWS || true |
| 59 | + hostname |
| 60 | + whoami |
| 61 | + pwd |
0 commit comments