mirror of https://github.com/rusefi/rusefi-ci.git
reworked to use runner token and added persistent operation
This commit is contained in:
parent
ed801ba6da
commit
5d5050bfd7
12
Dockerfile
12
Dockerfile
|
@ -19,15 +19,15 @@ RUN DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
|
||||||
dosfstools \
|
dosfstools \
|
||||||
zip
|
zip
|
||||||
|
|
||||||
WORKDIR /home/docker/actions-runner
|
WORKDIR /opt/actions-runner
|
||||||
|
|
||||||
# download and unzip the github 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 \
|
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 \
|
&& tar xf ./actions-runner-linux-x64-${RUNNER_VERSION}.tar.gz \
|
||||||
&& DEBIAN_FRONTEND=noninteractive /home/docker/actions-runner/bin/installdependencies.sh \
|
&& DEBIAN_FRONTEND=noninteractive /opt/actions-runner/bin/installdependencies.sh \
|
||||||
&& chown -R docker ~docker
|
&& chown -R docker /opt
|
||||||
|
|
||||||
WORKDIR /home/docker
|
WORKDIR /opt
|
||||||
|
|
||||||
COPY start.sh start.sh
|
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 \
|
&& 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
|
&& 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"]
|
ENTRYPOINT ["./start.sh"]
|
||||||
|
|
11
README.md
11
README.md
|
@ -1,17 +1,22 @@
|
||||||
# rusefi-ci
|
# 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:
|
To run, first build the image with:
|
||||||
|
|
||||||
`docker build -t rusefi-ci .`
|
`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
|
```bash
|
||||||
docker run --detach \
|
docker run --detach \
|
||||||
--ENV OWNER=ZHoob2004 \
|
--ENV OWNER=ZHoob2004 \
|
||||||
--ENV REPO=rusefi \
|
--ENV REPO=rusefi \
|
||||||
--ENV ACCESS_TOKEN=<PUT YO TOKEN HERE AND KEEP IT SECRET> \
|
--ENV REG_TOKEN=<PUT YO TOKEN HERE> \
|
||||||
rusefi-ci
|
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.
|
||||||
|
|
17
start.sh
17
start.sh
|
@ -2,20 +2,13 @@
|
||||||
|
|
||||||
OWNER=$OWNER
|
OWNER=$OWNER
|
||||||
REPO=$REPO
|
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
|
|
||||||
|
|
||||||
./config.sh --url https://github.com/${OWNER}/${REPO} --token ${REG_TOKEN} --unattended
|
if [ ! -f ".runner" ]; then
|
||||||
|
./config.sh --url https://github.com/${OWNER}/${REPO} --token ${REG_TOKEN} --unattended
|
||||||
cleanup() {
|
fi
|
||||||
echo "Removing runner..."
|
|
||||||
./config.sh remove --unattended --token ${REG_TOKEN}
|
|
||||||
}
|
|
||||||
|
|
||||||
trap 'cleanup; exit 130' INT
|
|
||||||
trap 'cleanup; exit 143' TERM
|
|
||||||
|
|
||||||
./run.sh & wait $!
|
./run.sh & wait $!
|
||||||
|
|
Loading…
Reference in New Issue