-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathget-runner-release.sh
More file actions
executable file
·37 lines (26 loc) · 1.11 KB
/
get-runner-release.sh
File metadata and controls
executable file
·37 lines (26 loc) · 1.11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#!/bin/sh
# Use the GitHub API to find the latest release of the GitHub Action runner,
# then download and extract the tarball for that release.
set -eE -o pipefail
release_file=/tmp/latest-runner-release.json
releases_api=https://api.github.com/repos/actions/runner/releases/latest
echo "Fetching latest release from $releases_api"
if [ ! $GITHUB_PAT = '' ]; then
# Set this to work around rate-limiting issues
echo "GITHUB_PAT is set; using for GitHub API"
auth_header="Authorization: token $GITHUB_PAT"
fi
curl -sSLf -H "$auth_header" -H 'Accept: application/json' -o $release_file $releases_api
latest_tag=$(jq -r '.tag_name' $release_file)
echo "Latest runner is ${latest_tag}"
echo $latest_tag >> ".RUNNER_VERSION"
rm $release_file
tag_without_v=$(echo $latest_tag | cut -c 2-)
os="linux" # could be "win" or "osx"
arch="x64" # for linux os, could be "arm" or "arm64"
runner_tar="actions-runner-${os}-${arch}-${tag_without_v}.tar.gz"
runner_url="https://github.com/actions/runner/releases/download/${latest_tag}/${runner_tar}"
set -x
curl -sSLf -O ${runner_url}
tar fxzp ${runner_tar}
rm ${runner_tar}