Skip to content

Commit

Permalink
feat: use RUNNER_NAME env
Browse files Browse the repository at this point in the history
  • Loading branch information
micdes-pagopa committed Dec 15, 2022
1 parent 33ed3ce commit 35ada60
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@ if [ -z "$GITHUB_REPOSITORY_BANNER" ]; then
fi

if [ -z "$RUNNER_NAME" ]; then
export RUNNER_NAME="$(hostname)"
export RUNNER_NAME="$(curl -s "${ECS_CONTAINER_METADATA_URI_V4}/task" \
| jq -r '.TaskARN' \
| cut -d "/" -f 3)"
fi

if [ -z "$WORK_DIR" ]; then
Expand All @@ -35,17 +37,13 @@ if [ "$(echo $REPLACE_EXISTING_RUNNER | tr '[:upper:]' '[:lower:]')" == "true" ]
REPLACEMENT_POLICY_LABEL="TRUE"
fi

ECS_TASK_ID=$(curl -s "${ECS_CONTAINER_METADATA_URI_V4}/task" \
| jq -r ".TaskARN" \
| cut -d "/" -f 3)

# Configure runner interactively, or with the given replacement policy.
printf "Configuring GitHub Runner for $GITHUB_REPOSITORY_BANNER\n"
printf "\tRunner Name: $RUNNER_NAME\n\tWorking Directory: $WORK_DIR\n\tReplace Existing Runners: $REPLACEMENT_POLICY_LABEL\n"
if [ "$INTERACTIVE" == "FALSE" ]; then
echo -ne "$REPLACEMENT_POLICY" | . /actions-runner/config.sh --name $ECS_TASK_ID --url $GITHUB_REPOSITORY --token $GITHUB_TOKEN --agent $RUNNER_NAME --work $WORK_DIR
echo -ne "$REPLACEMENT_POLICY" | . /actions-runner/config.sh --name $RUNNER_NAME --url $GITHUB_REPOSITORY --token $GITHUB_TOKEN --agent $RUNNER_NAME --work $WORK_DIR
else
. /actions-runner/config.sh --name $ECS_TASK_ID --url $GITHUB_REPOSITORY --token $GITHUB_TOKEN --agent $RUNNER_NAME --work $WORK_DIR
. /actions-runner/config.sh --name $RUNNER_NAME --url $GITHUB_REPOSITORY --token $GITHUB_TOKEN --agent $RUNNER_NAME --work $WORK_DIR
fi

# Start the runner.
Expand Down

0 comments on commit 35ada60

Please sign in to comment.