Watch for updates on GitHub Runner #1306
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: Watch for updates on GitHub Runner | |
on: | |
schedule: | |
- cron: "0 1 * * *" | |
workflow_dispatch: | |
jobs: | |
check-new-version: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout the code | |
uses: actions/checkout@v3 | |
- name: Get CURRENT (from file) and NEW (pro GH's API) versions of the runner | |
run: | | |
echo "NEW_VERSION=$(curl -s "https://api.github.com/repos/actions/runner/releases/latest" | jq --raw-output '.tag_name' | tr -d v)" >> $GITHUB_ENV | |
echo "CURRENT_VERSION=$(sed -n '/^ARG RUNNER_VERSION=/s///p' Dockerfile)" >> $GITHUB_ENV | |
- name: Update runner version on Dockerfile | |
if: ${{ env.NEW_VERSION != env.CURRENT_VERSION }} | |
run: | | |
sed "s|${CURRENT_VERSION}|${NEW_VERSION}|g" -i Dockerfile | |
echo 'PR_BODY<<EOF' >> $GITHUB_ENV | |
curl -s "https://raw.githubusercontent.com/actions/runner/main/releaseNote.md" >> $GITHUB_ENV | |
echo 'EOF' >> $GITHUB_ENV | |
- name: Open a new PR | |
if: ${{ env.NEW_VERSION != env.CURRENT_VERSION }} | |
uses: peter-evans/create-pull-request@v4 | |
with: | |
commit-message: Update GH Runner from ${{ env.CURRENT_VERSION }} to ${{ env.NEW_VERSION }} | |
title: "Update GH Runner from ${{ env.CURRENT_VERSION }} to ${{ env.NEW_VERSION }}" | |
branch: "update-runner-${{ env.NEW_VERSION }}" | |
body: ${{ env.PR_BODY }} | |
delete-branch: true | |
reviewers: "drigos,mat-machado" | |
assignees: "drigos,mat-machado" |