From 59c026736ba416a32d94b511ec1c826b262dad6a Mon Sep 17 00:00:00 2001 From: Michele De Simone <106953981+micdes-pagopa@users.noreply.github.com> Date: Wed, 7 Dec 2022 16:06:29 +0100 Subject: [PATCH] fix: run actions from user home directory (#2) --- .github/workflows/test.yaml | 1 + Dockerfile | 14 +++++++------- entrypoint.sh | 6 +++--- 3 files changed, 11 insertions(+), 10 deletions(-) diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index a317934..34d599f 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -43,6 +43,7 @@ jobs: delete_runner: name: Delete Self-Hosted Runner needs: [create_runner, test_job] + if: ${{ always() }} runs-on: ubuntu-22.04 environment: dev diff --git a/Dockerfile b/Dockerfile index 48f5d68..8975fe4 100644 --- a/Dockerfile +++ b/Dockerfile @@ -79,16 +79,16 @@ RUN curl https://baltocdn.com/helm/signing.asc | apt-key add - && \ RUN apt-get update && apt-get -y install helm - RUN useradd github && \ mkdir -p /home/github && \ chown -R github:github /home/github && \ - chown -R github:github /actions-runner + chown -R github:github /actions-runner && \ + chown -R github:github /usr/local/ -COPY entrypoint.sh /entrypoint.sh -RUN chmod +x /entrypoint.sh +WORKDIR /home/github -USER github +COPY entrypoint.sh ./entrypoint.sh +RUN chmod +x ./entrypoint.sh -WORKDIR / -ENTRYPOINT ["/entrypoint.sh"] +USER github +ENTRYPOINT ["/home/github/entrypoint.sh"] diff --git a/entrypoint.sh b/entrypoint.sh index 0d74973..c6a5775 100644 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -43,11 +43,11 @@ ECS_TASK_ID=$(curl -s "${ECS_CONTAINER_METADATA_URI_V4}/task" \ 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 $ECS_TASK_ID --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 $ECS_TASK_ID --url $GITHUB_REPOSITORY --token $GITHUB_TOKEN --agent $RUNNER_NAME --work $WORK_DIR fi # Start the runner. printf "Executing GitHub Runner for $GITHUB_REPOSITORY\n" -./actions-runner/run.sh +. /actions-runner/run.sh