Skip to content

Update Microcodes

Update Microcodes #14

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 flake.nix
run: |
OUTPUT=$(nix-prefetch-git --quiet https://github.com/platomav/CPUMicrocodes --rev refs/heads/master)
REV=$(echo "$OUTPUT" | jq -r .rev)
HASH=$(echo "$OUTPUT" | jq -r .hash)
echo "Fetched rev: $REV"
echo "Fetched hash: $HASH"
if ! grep -q "rev = \"$REV\";" flake.nix || ! grep -q "hash = \"$HASH\";" flake.nix; then
sed -i '/owner = "platomav"/{n;n;s|rev = ".*";|rev = "'"$REV"'";|}' flake.nix
sed -i '/owner = "platomav"/{n;n;n;s|hash = ".*";|hash = "'"$HASH"'";|}' flake.nix
git add flake.nix
if git diff --staged --quiet; then
echo "No changes to commit"
else
git commit -m "Update microcodes"
fi
else
echo "No changes to commit"
fi
- name: Update flake.lock
run: |
nix flake update --commit-lock-file --commit-lockfile-summary "Update inputs"
if [ ! -z "$(git ls-files --others)" ] || ! (git diff-index --quiet HEAD --); then
git add flake.lock
git commit -m "Update inputs"
fi
- name: Create PR
uses: peter-evans/create-pull-request@v6
with:
branch: update-microcodes
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"
body: "This PR updates the microcodes to the latest hash from the CPUMicrocodes repository."