Reputation: 325
I am trying below code in Dockerfile but I am getting error while I build the Docker image.
ENV GITHUB_RUNNER_VERSION=''
RUN $(curl --silent "https://api.github.com/repos/actions/runner/releases/latest" | jq -r '.tag_name[1:]') >> ${GITHUB_RUNNER_VERSION}
RUN curl -Ls https://github.com/actions/runner/releases/download/v$GITHUB_RUNNER_VERSION/actions-runner-linux-x64-$GITHUB_RUNNER_VERSION.tar.gz | tar zx \
&& chown -R github:github /work \
&& sudo ./bin/installdependencies.sh
Error:
Step 10/20 : RUN curl --silent "https://api.github.com/repos/actions/runner/releases/latest" | jq -r '.tag_name[1:]' >> ${GITHUB_RUNNER_VERSION}
---> Running in a827248e3eb4
/bin/sh: 1: cannot create : Directory nonexistent
The command '/bin/sh -c curl --silent "https://api.github.com/repos/actions/runner/releases/latest" | jq -r '.tag_name[1:]' >> ${GITHUB_RUNNER_VERSION}' returned a non-zero code: 2
Error: exit status 2
Upvotes: 0
Views: 1226
Reputation: 792
You can use this to get the latest URL:
curl -s https://api.github.com/repos/actions/runner/releases/latest | jq -r .assets[].browser_download_url | grep "linux-x64"
If you want to download it in one command, you can use:
curl -sLO $(curl -s https://api.github.com/repos/actions/runner/releases/latest | jq -r .assets[].browser_download_url | grep "linux-x64")
Upvotes: 0
Reputation: 83393
curl -s https://github.com/actions/runner/tags/ | grep -Eo " v[0-9]+.[0-9]+.[0-9]+" | head -n1 | tr -d 'v '
Upvotes: 0
Reputation: 23056
I use a slightly different technique for determining the latest version, but the key to success here is to use an environment variable set in the same RUN
command that downloads the runner itself:
RUN RUNNER_VERSION=$(curl -s "https://github.com/actions/runner/tags/" | grep -Eo "$Version v[0-9]+.[0-9]+.[0-9]+" | sort -r | head -n1 | tr -d ' ' | tr -d 'v') \
&& cd /home/runner \
&& curl -O -L https://github.com/actions/runner/releases/download/v${RUNNER_VERSION}/actions-runner-linux-x64-${RUNNER_VERSION}.tar.gz \
&& tar xzf ./actions-runner-linux-x64-${RUNNER_VERSION}.tar.gz
You could just use this (noting that it only downloads and decompresses the runner; dependencies are installed in a separate step) or, assuming that everything else in your dockerfile is correct, your command above should work if combined into the single RUN
statement:
RUN GITHUB_RUNNER_VERSION=$(curl --silent "https://api.github.com/repos/actions/runner/releases/latest" | jq -r '.tag_name[1:]') \
&& curl -Ls https://github.com/actions/runner/releases/download/v${GITHUB_RUNNER_VERSION}/actions-runner-linux-x64-$GITHUB_RUNNER_VERSION.tar.gz | tar zx \
&& chown -R github:github /work \
&& sudo ./bin/installdependencies.sh
Upvotes: 0