Update Microcodes #25
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: Update Microcodes | |
on: | |
schedule: | |
- cron: "0 0 * * 1" # Runs every Monday at midnight | |
workflow_dispatch: # Allows manual trigger of the workflow | |
permissions: | |
pull-requests: write | |
contents: write | |
jobs: | |
update-microcodes: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Install Nix | |
uses: cachix/install-nix-action@v27 | |
with: | |
nix_path: nixpkgs=channel:nixos-unstable | |
- name: Install dependencies | |
run: | | |
nix-env -iA nix-prefetch-git -f '<nixpkgs>' | |
nix-env -iA jq -f '<nixpkgs>' | |
- name: Setup git | |
run: | | |
git config --local user.name "github-actions[bot]" | |
git config --local user.email "github-actions[bot]@users.noreply.github.com" | |
- name: Update microcodes | |
run: | | |
OUTPUT=$(nix-prefetch-git --quiet https://github.com/platomav/CPUMicrocodes --rev refs/heads/master) | |
REV=$(echo "$OUTPUT" | jq -r .rev) | |
SHORT_REV=$(echo "$REV" | cut -c1-7) | |
echo "Fetched rev: $REV (short: $SHORT_REV)" | |
echo "rev=$REV" >> $GITHUB_ENV | |
echo "shortRev=$SHORT_REV" >> $GITHUB_ENV | |
if ! grep -q "url = \"github:platomav/CPUMicrocodes/$REV\";" flake.nix; then | |
echo "Updating flake input to rev: $REV" | |
sed -i 's|url = "github:platomav/CPUMicrocodes/.*";|url = "github:platomav/CPUMicrocodes/'"$REV"'";|' flake.nix | |
git add flake.nix | |
git commit -m "Update CPUMicrocodes flake input" | |
echo "Commit created for new input revision." | |
else | |
echo "No changes to commit. Already up to date with rev: $REV" | |
fi | |
- name: Create PR | |
uses: peter-evans/create-pull-request@v6 | |
with: | |
branch: update-microcodes-${{ env.shortRev }} | |
delete-branch: true | |
committer: github-actions[bot] <github-actions[bot]@users.noreply.github.com> | |
author: github-actions[bot] <github-actions[bot]@users.noreply.github.com> | |
title: "Update CPUMicrocodes input to ${{ env.shortRev }}" | |
body: "This PR sets the CPUMicrocodes flake input to the latest revision, updating the microcode binaries." |