Fetching the most recent GitHub actions runner version

  • Post author:
  • Post category:GitHub

One of the struggles I have with running self-hosted GitHub actions runners is that GitHub releases new versions of the runner quite often and I don't notice. That's fine as long as you ignore the scary warnings on action output, until they drop support for whatever random old runner you're using. They did just that to me this week. The best bit was that the "old runner" was only a month old! I was left wondering if I could automate this. The answer is thankfully yes. Specifically, I wanted to automate it with a GitHub action which downloads the runner and puts it into the self-hosted runner image. That looks like this: - name: Install the github command line run: | sudo apt update sudo apt install -y curl curl -fsSL https://cli.github.com/packages/githubcli-archive-keyring.gpg | sudo dd of=/usr/share/keyrings/githubcli-archive-keyring.gpg sudo chmod go+r /usr/share/keyrings/githubcli-archive-keyring.gpg echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/githubcli-archive-keyring.gpg] https://cli.github.com/packages stable main" | sudo tee /etc/apt/sources.list.d/github-cli.list > /dev/null sudo apt update sudo apt install -y gh - name: Lookup latest version of the GitHub actions runner env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | actions_url=$(gh release view --repo actions/runner --json assets | \ jq -r '.assets[].url | select (contains("linux-x64-2")) | select (test("[0-9].tar.gz$"))') echo "GITHUB_ACTIONS_URL=$actions_url" >>…

Continue ReadingFetching the most recent GitHub actions runner version

End of content

No more pages to load