Skip to content

Commit

Permalink
Merge branch 'develop' into chore/mvlookup
Browse files Browse the repository at this point in the history
  • Loading branch information
lispc authored Jan 31, 2024
2 parents a1c5126 + 93bc24e commit 7e65f58
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 25 deletions.
48 changes: 23 additions & 25 deletions .github/ciChecksScripts/wakeUpRunner.sh
Original file line number Diff line number Diff line change
@@ -1,49 +1,47 @@
#!/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
else
sleep 30
fi
done

exit 0
10 changes: 10 additions & 0 deletions .github/workflows/select-runner.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 7e65f58

Please sign in to comment.