From 7c758d1b2d872df670b547a540f0853cf19436f3 Mon Sep 17 00:00:00 2001 From: "Mikhail f. Shiryaev" Date: Thu, 16 Nov 2023 15:30:16 +0100 Subject: [PATCH] Define the INIT_ENVIRONMENT through instances tags --- tests/ci/worker/init_runner.sh | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/tests/ci/worker/init_runner.sh b/tests/ci/worker/init_runner.sh index a2737575955..0b610a108f3 100644 --- a/tests/ci/worker/init_runner.sh +++ b/tests/ci/worker/init_runner.sh @@ -5,10 +5,10 @@ The following content is embedded into the s3 object via the script deploy-runner-init.sh {staging,production} with additional helping information -In the `user data` you should define as the following -with appropriate as 'staging' or 'production': +In the `user data` you should define as the following text +between `### COPY BELOW` and `### COPY ABOVE` -### COPY AFTER +### COPY BELOW Content-Type: multipart/mixed; boundary="//" MIME-Version: 1.0 @@ -29,11 +29,14 @@ Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="userdata.txt" #!/bin/bash -aws s3 cp s3://github-runners-data/cloud-init/.sh /tmp/cloud-init.sh +INSTANCE_ID=$(ec2metadata --instance-id) +INIT_ENVIRONMENT=$(/usr/local/bin/aws ec2 describe-tags --filters "Name=resource-id,Values=$INSTANCE_ID" --query "Tags[?Key=='github:init-environment'].Value" --output text) +echo "Downloading and using $INIT_ENVIRONMENT cloud-init.sh" +aws s3 cp "s3://github-runners-data/cloud-init/${INIT_ENVIRONMENT:-production}.sh" /tmp/cloud-init.sh chmod 0700 /tmp/cloud-init.sh exec bash /tmp/cloud-init.sh --// -### COPY BEFORE +### COPY ABOVE EOF # THE SCRIPT START