Skip to content

Update github-actions-runners-updates.yml #132

Update github-actions-runners-updates.yml

Update github-actions-runners-updates.yml #132

# Look for differences in GitHub Actions runner versions and the unique runner names (NOT THE PRE-RELEASES)
# The action fails if there are differences and the failure will be used to trigger the ss3-build.yml
# and the build-admb-and-ss3.yml to make sure that the actions still run with the updated runner versions
# If the unique runner names are different then you should add or take away runners accordingly and test
# ss3-build.yml and build-admb-and-ss3.yml with those.
name: github-actions-runners-updates
on:
push:
workflow_dispatch:
schedule:
- cron: '0 15 * * 2' #min, hour, day of the month, month, day of the week
jobs:
github-actions-runners-updates:
runs-on: ubuntu-latest
env:
R_REMOTES_NO_ERRORS_FROM_WARNINGS: true
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
R_KEEP_PKG_SOURCE: yes
steps:
- name: Checkout repo
uses: actions/checkout@v4
- name: Setup R
uses: r-lib/actions/setup-r@v2
- name: Get all github actions runner releases and list the unique runner names (not including pre-releases)
run: |
RELEASES=$(curl -s https://api.github.com/repos/actions/runner-images/releases)
RELEASES_ALL=$(echo "$RELEASES" | jq -r '.[] | select(.prerelease == false) | .tag_name' | sort -r)
RELEASES_UNIQUE=$(echo "$RELEASES_ALL" |awk -F'/' '{print $1}'| sort -u)
echo "$RELEASES_UNIQUE" > releases_names_unique_new.txt
echo "$RELEASES_UNIQUE"
test -f releases_names_unique_new.txt
- name: See if any there are any new runners based on the reference file
id: runner_diff
run: |
all_runners_previous <- readLines(".github/ref_file/releases_names_unique.txt")
all_runners_new <- readLines("releases_names_unique_new.txt")
if(any(all_runners_new != all_runners_previous)){
cat(sprintf('output_runners=%s', 'differences in runners'), file = Sys.getenv("GITHUB_OUTPUT"), append = TRUE)
}
print(all_runners_new[all_runners_new != all_runners_previous])
runner_names_compare <- all_runners_new[all_runners_new != all_runners_previous]
file.create("runner_names_compare.txt")
writeLines(runner_names_compare, "runner_names_compare.txt")
shell: Rscript {0}
- name: Get latest release ubuntu
run: |
RELEASES=$(curl -s https://api.github.com/repos/actions/runner-images/releases)
RELEASE_UBUNTU=$(echo "$RELEASES" | jq -r '.[] | select(.prerelease == false) | .tag_name' | sort -r| grep ubuntu22 | head -n1)
echo "$RELEASE_UBUNTU" > ubuntu.txt
echo "$RELEASE_UBUNTU"
- name: Get latest release macos-13
run: |
RELEASES=$(curl -s https://api.github.com/repos/actions/runner-images/releases)
RELEASE_MACOS13=$(echo "$RELEASES" | jq -r '.[] | select(.prerelease == false) | .tag_name' | sort -r | grep macos-13 | head -n1)
echo "$RELEASE_MACOS13" > macos-13.txt
echo "$RELEASE_MACOS13"
- name: Get latest release macos-14
run: |
RELEASES=$(curl -s https://api.github.com/repos/actions/runner-images/releases)
RELEASE_MACOS14=$(echo "$RELEASES" | jq -r '.[] | select(.prerelease == false) | .tag_name' | sort -r | grep macos-14-arm64 | head -n1)
echo "$RELEASE_MACOS14" > macos-14.txt
echo "$RELEASE_MACOS14"
- name: Get latest release macos-15
run: |
RELEASES=$(curl -s https://api.github.com/repos/actions/runner-images/releases)
RELEASE_MACOS15=$(echo "$RELEASES" | jq -r '.[] | select(.prerelease == false) | .tag_name' | sort -r | grep macos-15-arm64 | head -n1)
echo "$RELEASE_MACOS15" > macos-15.txt
echo "$RELEASE_MACOS15"
- name: Get latest release windows 2022
run: |
RELEASES=$(curl -s https://api.github.com/repos/actions/runner-images/releases)
RELEASE_WINDOWS=$(echo "$RELEASES" | jq -r '.[] | select(.prerelease == false) | .tag_name' | sort -r | grep win22 | head -n1)
echo "$RELEASE_WINDOWS" > windows.txt
echo "$RELEASE_WINDOWS"
- name: Get latest release windows 2025
run: |
RELEASES=$(curl -s https://api.github.com/repos/actions/runner-images/releases)
RELEASE_WINDOWS25=$(echo "$RELEASES" | jq -r '.[] | select(.prerelease == false) | .tag_name' | sort -r | grep win25 | head -n1)
echo "$RELEASE_WINDOWS25" > windows25.txt
echo "$RELEASE_WINDOWS25"
- name: Read in txt files of releases and see if there are any differences in release versions from the reference file
id: version_diff
run: |
ubuntu <- readLines("ubuntu.txt")
macos13 <- readLines("macos-13.txt")
macos14 <- readLines("macos-14.txt")
macos15 <- readLines("macos-15.txt")
windows <- readLines("windows.txt")
windows25 <- readLines("windows25.txt")
all_os <- capture.output(cat(ubuntu, macos13, macos14, macos15, windows, windows25, sep = "\n"))
file.create("all_os_versions_new.txt")
writeLines(all_os, "all_os_versions_new.txt")
all_os_previous <- readLines(".github/ref_file/all_os_versions.txt")
all_os_new <- readLines("all_os_versions_new.txt")
if(any(all_os_new != all_os_previous)){
cat(sprintf('output_ver=%s', 'differences in runner versions'), file = Sys.getenv("GITHUB_OUTPUT"), append = TRUE)
}
print(all_os_new[all_os_new != all_os_previous])
runner_versions_compare <- all_os_new[all_os_new != all_os_previous]
file.create("runner_versions_compare.txt")
writeLines(runner_versions_compare, "runner_versions_compare.txt")
shell: Rscript {0}
- name: Move new version of runner versions and unique runner names
if: steps.version_diff.outputs.output_ver == 'differences in runner versions' || steps.runner_diff.outputs.output_runners == 'differences in runners'
run: |
rm ubuntu.txt macos-13.txt macos-14.txt macos-15.txt windows.txt windows25.txt
mv all_os_versions_new.txt .github/ref_file/all_os_versions.txt
mv releases_names_unique_new.txt .github/ref_file/releases_names_unique.txt
- name: Create artifact of runner name differences
if: steps.runner_diff.outputs.output_runners == 'differences in runners'
uses: actions/upload-artifact@main
with:
name: 'runner_names_compare.txt'
path: runner_names_compare.txt
- name: Create artifact of version differences
if: steps.version_diff.outputs.output_ver == 'differences in runner versions'
uses: actions/upload-artifact@main
with:
name: 'runner_versions_compare.txt'
path: runner_versions_compare.txt
- name: remove compare files
run: |
rm runner_names_compare.txt runner_versions_compare.txt
- name: Create Pull Request for new github action runner ref files
if: steps.version_diff.outputs.output_ver == 'differences in runner versions' || steps.runner_diff.outputs.output_runners == 'differences in runners'
uses: peter-evans/create-pull-request@v6
with:
commit-message: Update GitHub action runner ref files
committer: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
author: ${{ github.actor }} <${{ github.actor_id }}+${{ github.actor }}@users.noreply.github.com>
branch: update-gha-runner-ref-files
delete-branch: true
title: 'Update GitHub action runner ref files'
body: |
- Updated GitHub action runner version ref file with new runner versions and/or changed runner names
- See changes in the ref file under the `Files changed` tab
- Auto-generated by [create-pull-request][1]
[1]: https://github.com/peter-evans/create-pull-request
reviewers: e-perl-NOAA
draft: false
# - Version changes (if any): ${{ steps.version_diff.outputs.diff_ver }}
# - Runner changes (if any): ${{ steps.runner_diff.outputs.diff_runners }}
- name: Fail action if differences in runner versions or unique runner names
if: steps.version_diff.outputs.output_ver == 'differences in runner versions' || steps.runner_diff.outputs.output_runners == 'differences in runners'
run: |
echo 'GitHub actions runner versions have changed and/or the runner names have changed'
echo 'Running build-ss3.yml and build-admb-and-ss3.yml to make sure they still work with updated runner versions'
echo 'If runner names have changed you will need to add or takeaway the changed runners to make sure the workflows still run'
exit 1