Get latest release for github actions runner and update if required #23727
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Get latest release for github actions runner and update if required | |
on: | |
schedule: | |
- cron: '0 * * * *' | |
jobs: | |
update-version: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v2 | |
- name: Fetch release version | |
id: getrelease | |
run: | | |
echo ::set-output name=release_tag::$(curl -sL https://api.github.com/repos/actions/runner/releases/latest | jq '.tag_name' | sed 's/"//g' | sed 's/^v//') | |
- name: Read internal update version | |
id: getversion | |
run: echo "::set-output name=version::$(grep 'ARG RUNNER_VERSION' github-actions-runner/Dockerfile | awk -F'=' '{print $2}')" | |
- name: Update runner in container | |
if: steps.getrelease.outputs.release_tag != steps.getversion.outputs.version && steps.getrelease.outputs.release_tag != 'null' | |
env: | |
RELEASE_NO: ${{ steps.getrelease.outputs.release_tag }} | |
CURRENT_VERSION: ${{ steps.getversion.outputs.version }} | |
run: | | |
sed -i "s/ARG RUNNER_VERSION=$CURRENT_VERSION/ARG RUNNER_VERSION=$RELEASE_NO/" github-actions-runner/Dockerfile | |
- name: Create Pull Request | |
id: cpr | |
uses: peter-evans/create-pull-request@v3 | |
with: | |
commit-message: Update actions runner to ${{ steps.getrelease.outputs.release_tag }} | |
title: Update actions runner to ${{ steps.getrelease.outputs.release_tag }} | |
body: | | |
Updates [runner][1] to ${{ steps.getrelease.outputs.release_tag }} | |
Auto-generated by [create-pull-request][2] | |
[1]: https://github.com/actions/runner | |
[2]: https://github.com/peter-evans/create-pull-request | |
labels: dependencies, automated pr | |
branch: actions-runner-updates | |
reviewers: pmb59,anilthanki,irisdianauy | |
- name: Enable Pull Request Automerge | |
if: steps.cpr.outputs.pull-request-operation == 'created' | |
uses: peter-evans/enable-pull-request-automerge@v1 | |
with: | |
token: ${{ secrets.PAT }} | |
pull-request-number: ${{ steps.cpr.outputs.pull-request-number }} | |
merge-method: squash | |
- name: Auto approve | |
if: steps.cpr.outputs.pull-request-operation == 'created' | |
uses: juliangruber/approve-pull-request-action@v1 | |
with: | |
github-token: ${{ secrets.PAT }} | |
number: ${{ steps.cpr.outputs.pull-request-number }} |