Skip to content

Commit

Permalink
Conditional
Browse files Browse the repository at this point in the history
  • Loading branch information
ryaneggz committed Aug 21, 2023
1 parent 5f74e49 commit c25f9e7
Showing 1 changed file with 15 additions and 21 deletions.
36 changes: 15 additions & 21 deletions .github/workflows/repo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,30 +27,24 @@ jobs:
if [ ! -z "$EXISTING_TASKS" ]; then
echo "A task for the Task Definition: $TASK_DEF_NAME is already running in the Cluster: $CLUSTER_NAME."
echo "::set-output name=taskExists::true"
else
echo "::set-output name=taskExists::false"
# Fetch the first available subnet in the region
SUBNETS=$(aws ec2 describe-subnets --region $AWS_DEFAULT_REGION --query 'Subnets[0].SubnetId' --output text)
# Optionally, fetch the first available security group in the region
SEC_GROUPS=$(aws ec2 describe-security-groups --region $AWS_DEFAULT_REGION --query 'SecurityGroups[0].GroupId' --output text)
echo "Using Subnet: $SUBNETS"
echo "Using Security Group: $SEC_GROUPS"
aws ecs run-task \
--region $AWS_DEFAULT_REGION \
--cluster $CLUSTER_NAME \
--task-definition $TASK_DEF_NAME \
--launch-type FARGATE \
--network-configuration "awsvpcConfiguration={subnets=[$SUBNETS],securityGroups=[$SEC_GROUPS],assignPublicIp=ENABLED}"
fi
- name: Start Fargate runner
if: steps.checkrunner.outputs.taskExists == 'false'
run: |
# Fetch the first available subnet in the region
SUBNETS=$(aws ec2 describe-subnets --region $AWS_DEFAULT_REGION --query 'Subnets[0].SubnetId' --output text)
# Optionally, fetch the first available security group in the region
SEC_GROUPS=$(aws ec2 describe-security-groups --region $AWS_DEFAULT_REGION --query 'SecurityGroups[0].GroupId' --output text)
echo "Using Subnet: $SUBNETS"
echo "Using Security Group: $SEC_GROUPS"
aws ecs run-task \
--region $AWS_DEFAULT_REGION \
--cluster $CLUSTER_NAME \
--task-definition $TASK_DEF_NAME \
--launch-type FARGATE \
--network-configuration "awsvpcConfiguration={subnets=[$SUBNETS],securityGroups=[$SEC_GROUPS],assignPublicIp=ENABLED}"
setup:
needs: runner
runs-on: self-hosted
Expand Down

0 comments on commit c25f9e7

Please sign in to comment.