|
| 1 | +name: Check GitHub Actions Runner Version |
| 2 | + |
| 3 | +on: |
| 4 | + schedule: |
| 5 | + # Run every weekday at 9 AM UTC |
| 6 | + - cron: '0 9 * * 1-5' |
| 7 | + workflow_dispatch: |
| 8 | + |
| 9 | +permissions: |
| 10 | + contents: write |
| 11 | + pull-requests: write |
| 12 | + |
| 13 | +jobs: |
| 14 | + check-version: |
| 15 | + runs-on: ubuntu-latest |
| 16 | + steps: |
| 17 | + - name: Checkout repository |
| 18 | + uses: actions/checkout@v4 |
| 19 | + |
| 20 | + - name: Get current runner version |
| 21 | + id: current-version |
| 22 | + run: | |
| 23 | + CURRENT_VERSION=$(grep "RUNNER_VER=" vm/setup.sh | cut -d'=' -f2) |
| 24 | + echo "current=$CURRENT_VERSION" >> $GITHUB_OUTPUT |
| 25 | + echo "Current runner version: $CURRENT_VERSION" |
| 26 | +
|
| 27 | + - name: Get latest runner version |
| 28 | + id: latest-version |
| 29 | + run: | |
| 30 | + LATEST_VERSION=$(curl -s https://api.github.com/repos/actions/runner/releases/latest | jq -r '.tag_name' | sed 's/^v//') |
| 31 | + echo "latest=$LATEST_VERSION" >> $GITHUB_OUTPUT |
| 32 | + echo "Latest runner version: $LATEST_VERSION" |
| 33 | +
|
| 34 | + - name: Compare versions |
| 35 | + id: compare |
| 36 | + run: | |
| 37 | + if [ "${{ steps.current-version.outputs.current }}" != "${{ steps.latest-version.outputs.latest }}" ]; then |
| 38 | + echo "needs_update=true" >> $GITHUB_OUTPUT |
| 39 | + echo "Version update needed: ${{ steps.current-version.outputs.current }} -> ${{ steps.latest-version.outputs.latest }}" |
| 40 | + else |
| 41 | + echo "needs_update=false" >> $GITHUB_OUTPUT |
| 42 | + echo "Runner version is up to date" |
| 43 | + fi |
| 44 | +
|
| 45 | + - name: Create PR for version update |
| 46 | + if: steps.compare.outputs.needs_update == 'true' |
| 47 | + env: |
| 48 | + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 49 | + run: | |
| 50 | + CURRENT_VERSION="${{ steps.current-version.outputs.current }}" |
| 51 | + LATEST_VERSION="${{ steps.latest-version.outputs.latest }}" |
| 52 | + BRANCH_NAME="update-runner-version-$LATEST_VERSION" |
| 53 | + |
| 54 | + # Configure git |
| 55 | + git config user.name "github-actions[bot]" |
| 56 | + git config user.email "github-actions[bot]@users.noreply.github.com" |
| 57 | + |
| 58 | + # Create and switch to new branch |
| 59 | + git checkout -b "$BRANCH_NAME" |
| 60 | + |
| 61 | + # Update the runner version in setup.sh |
| 62 | + sed -i "s/RUNNER_VER=$CURRENT_VERSION/RUNNER_VER=$LATEST_VERSION/" vm/setup.sh |
| 63 | + |
| 64 | + # Commit changes |
| 65 | + git add vm/setup.sh |
| 66 | + git commit -m "Update GitHub Actions runner to v$LATEST_VERSION" |
| 67 | + |
| 68 | + # Push branch |
| 69 | + git push origin "$BRANCH_NAME" |
| 70 | + |
| 71 | + # Create PR |
| 72 | + gh pr create \ |
| 73 | + --title "Update GitHub Actions runner to v$LATEST_VERSION" \ |
| 74 | + --body "This PR updates the GitHub Actions runner version from \`$CURRENT_VERSION\` to \`$LATEST_VERSION\`." \ |
| 75 | + --head "$BRANCH_NAME" \ |
| 76 | + --base main |
0 commit comments