diff --git a/.github/ciChecksScripts/wakeUpRunner.sh b/.github/ciChecksScripts/wakeUpRunner.sh index d2df36b925..c16c2a0de3 100755 --- a/.github/ciChecksScripts/wakeUpRunner.sh +++ b/.github/ciChecksScripts/wakeUpRunner.sh @@ -1,43 +1,43 @@ #!/bin/bash profile="cirunner" -runner_vpc_id1="vpc-8bdf97ec" -runner_vpc_id2="vpc-1176d875" +runner_vpc_id="vpc-0323d32f82edcdec7" region_opt="--region us-west-2" # Get runner status -runner1=$(aws ec2 describe-instances --profile $profile --filters Name=tag:Name,Values=[jenkins] Name=network-interface.vpc-id,Values=[$runner_vpc_id1] --query "Reservations[*].Instances[*][InstanceId]" ${region_opt} --output text | xargs) -runner2=$(aws ec2 describe-instances --profile $profile --filters Name=tag:Name,Values=[jenkins] Name=network-interface.vpc-id,Values=[$runner_vpc_id2] --query "Reservations[*].Instances[*][InstanceId]" --output text | xargs) +runner1=$(aws ec2 describe-instances --profile $profile --filters Name=tag:Name,Values=[super1] Name=network-interface.vpc-id,Values=[$runner_vpc_id] --query "Reservations[*].Instances[*][InstanceId]" ${region_opt} --output text | xargs) +runner2=$(aws ec2 describe-instances --profile $profile --filters Name=tag:Name,Values=[super2] Name=network-interface.vpc-id,Values=[$runner_vpc_id] --query "Reservations[*].Instances[*][InstanceId]" ${region_opt} --output text | xargs) -{ - while true; do +# start runner1 +while true; do + runner_status=$(aws ec2 describe-instances --profile $profile --instance-ids $runner1 --query "Reservations[*].Instances[*].State.[Name]" ${region_opt} --output text) + echo 'runner1 - '$runner_status + if [[ $runner_status = "stopped" ]]; then + aws ec2 start-instances --profile $profile --instance-ids $runner1 ${region_opt} + break + elif [[ $runner_status = "running" ]]; then + echo 'waiting for runner1 restore' + sleep 30 runner_status=$(aws ec2 describe-instances --profile $profile --instance-ids $runner1 --query "Reservations[*].Instances[*].State.[Name]" ${region_opt} --output text) - echo 'runner1 - '$runner_status - if [[ $runner_status = "stopped" ]]; then - aws ec2 start-instances --profile $profile --instance-ids $runner1 ${region_opt} + if [[ $runner_status = "running" ]]; then break - elif [[ $runner_status = "running" ]]; then - echo 'waiting for runner1 restore' - sleep 30 - runner_status=$(aws ec2 describe-instances --profile $profile --instance-ids $runner1 --query "Reservations[*].Instances[*].State.[Name]" ${region_opt} --output text) - if [[ $runner_status = "running" ]]; then - break - fi - else - sleep 30 fi - done -}& + else + sleep 30 + fi +done + +# start runner2 while true; do - runner_status=$(aws ec2 describe-instances --profile $profile --instance-ids $runner2 --query "Reservations[*].Instances[*].State.[Name]" --output text) + runner_status=$(aws ec2 describe-instances --profile $profile --instance-ids $runner2 --query "Reservations[*].Instances[*].State.[Name]" ${region_opt} --output text) echo 'runner2 - '$runner_status if [[ $runner_status = "stopped" ]]; then - aws ec2 start-instances --profile $profile --instance-ids $runner2 + aws ec2 start-instances --profile $profile --instance-ids $runner2 ${region_opt} break elif [[ $runner_status = "running" ]]; then echo 'waiting for runner2 restore' sleep 30 - runner_status=$(aws ec2 describe-instances --profile $profile --instance-ids $runner2 --query "Reservations[*].Instances[*].State.[Name]" --output text) + runner_status=$(aws ec2 describe-instances --profile $profile --instance-ids $runner2 --query "Reservations[*].Instances[*].State.[Name]" ${region_opt} --output text) if [[ $runner_status = "running" ]]; then break fi @@ -45,5 +45,3 @@ while true; do sleep 30 fi done - -exit 0 diff --git a/.github/workflows/select-runner.yml b/.github/workflows/select-runner.yml index 4aee2fc9db..68394718b4 100644 --- a/.github/workflows/select-runner.yml +++ b/.github/workflows/select-runner.yml @@ -38,3 +38,13 @@ jobs: outputs: matrix1: ${{ toJSON( fromJSON(inputs.matrices)[1] ) }} matrix2: ${{ toJSON( fromJSON(inputs.matrices)[2] ) }} + + wakeup: + name: Wake up self-hosted runner + if: ${{ inputs.enabled }} + needs: [select] + runs-on: ${{ inputs.bastion-host }} + concurrency: ${{ needs.select.outputs.matrix1 }} + steps: + - uses: actions/checkout@v4 + - run: .github/ciChecksScripts/wakeUpRunner.sh