Skip to content

Commit

Permalink
fix: run actions from user home directory (#2)
Browse files Browse the repository at this point in the history
  • Loading branch information
micdes-pagopa authored Dec 7, 2022
1 parent cf6eab1 commit 59c0267
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 10 deletions.
1 change: 1 addition & 0 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
14 changes: 7 additions & 7 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
6 changes: 3 additions & 3 deletions entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 59c0267

Please sign in to comment.