reworked to use runner token and added persistent operation

This commit is contained in:
zhoob2004 2021-11-17 15:03:18 -07:00
parent ed801ba6da
commit 5d5050bfd7
3 changed files with 20 additions and 20 deletions

View File

@ -19,15 +19,15 @@ RUN DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
dosfstools \
zip
WORKDIR /home/docker/actions-runner
WORKDIR /opt/actions-runner
# download and unzip the github actions runner
RUN curl -O -L https://github.com/actions/runner/releases/download/v${RUNNER_VERSION}/actions-runner-linux-x64-${RUNNER_VERSION}.tar.gz \
&& tar xf ./actions-runner-linux-x64-${RUNNER_VERSION}.tar.gz \
&& DEBIAN_FRONTEND=noninteractive /home/docker/actions-runner/bin/installdependencies.sh \
&& chown -R docker ~docker
&& DEBIAN_FRONTEND=noninteractive /opt/actions-runner/bin/installdependencies.sh \
&& chown -R docker /opt
WORKDIR /home/docker
WORKDIR /opt
COPY start.sh start.sh
@ -40,6 +40,8 @@ RUN curl -L -O https://developer.arm.com/-/media/Files/downloads/gnu-rm/9-2020q2
&& tar -xf gcc-arm-none-eabi-9-2020-q2-update-x86_64-linux.tar.bz2 \
&& rm gcc-arm-none-eabi-9-2020-q2-update-x86_64-linux.tar.bz2
ENV PATH $PATH:/home/docker/gcc-arm-none-eabi-9-2020-q2-update/bin
ENV PATH $PATH:/opt/gcc-arm-none-eabi-9-2020-q2-update/bin
VOLUME /opt/actions-runner
ENTRYPOINT ["./start.sh"]

View File

@ -1,17 +1,22 @@
# rusefi-ci
This script will automatically download and configure the github actions self-hosted runner and dynamically register it to the repo given in $OWNER/$REPO
This script will automatically download and configure the github actions self-hosted runner
To run, first build the image with:
`docker build -t rusefi-ci .`
Then run the newly built image passing `OWNER`, `REPO`, and `ACCESS_TOKEN` (your personal github access token, keep this safe!)
Then run the newly built image passing `OWNER`, `REPO`, and `REG_TOKEN` (time-limited github actions registration token)
```bash
docker run --detach \
--ENV OWNER=ZHoob2004 \
--ENV REPO=rusefi \
--ENV ACCESS_TOKEN=<PUT YO TOKEN HERE AND KEEP IT SECRET> \
--ENV REG_TOKEN=<PUT YO TOKEN HERE> \
rusefi-ci
```
add `--restart=unless-stopped` in order to have the container survive reboots
The container uses a persistent volume mounted at /opt/actions-runner. After initial startup, the container will skip registration unless the peristent volume is erased.

View File

@ -2,20 +2,13 @@
OWNER=$OWNER
REPO=$REPO
ACCESS_TOKEN=$ACCESS_TOKEN
REG_TOKEN=$REG_TOKEN
REG_TOKEN=$(curl -sX POST -H "Authorization: token ${ACCESS_TOKEN}" https://api.github.com/repos/${OWNER}/${REPO}/actions/runners/registration-token | jq .token --raw-output)
cd /opt/actions-runner
cd /home/docker/actions-runner
if [ ! -f ".runner" ]; then
./config.sh --url https://github.com/${OWNER}/${REPO} --token ${REG_TOKEN} --unattended
cleanup() {
echo "Removing runner..."
./config.sh remove --unattended --token ${REG_TOKEN}
}
trap 'cleanup; exit 130' INT
trap 'cleanup; exit 143' TERM
fi
./run.sh & wait $!