Files
RSSHub/.github/workflows/update-nix-hash.yml
T
dependabot[bot] be4951ef95 chore(deps): bump cachix/install-nix-action from 31.10.0 to 31.10.1 (#21351)
Bumps [cachix/install-nix-action](https://github.com/cachix/install-nix-action) from 31.10.0 to 31.10.1.
- [Release notes](https://github.com/cachix/install-nix-action/releases)
- [Changelog](https://github.com/cachix/install-nix-action/blob/master/RELEASE.md)
- [Commits](https://github.com/cachix/install-nix-action/compare/19effe9fe722874e6d46dd7182e4b8b7a43c4a99...1ca7d21a94afc7c957383a2d217460d980de4934)

---
updated-dependencies:
- dependency-name: cachix/install-nix-action
  dependency-version: 31.10.1
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2026-03-11 08:21:35 +00:00

69 lines
2.6 KiB
YAML

name: Update Nix Hash
on:
push:
branches:
- master
paths:
- 'pnpm-lock.yaml'
permissions:
contents: write
jobs:
update-hash:
# Only run on the upstream repo, not forks
if: github.repository_owner == 'DIYgod'
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- name: Checkout
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- name: Install Nix
uses: cachix/install-nix-action@1ca7d21a94afc7c957383a2d217460d980de4934 # v31.10.1
with:
nix_path: nixpkgs=channel:nixos-unstable
- name: Update Nix flake hash
id: update-hash
run: |
set -e
# Extract current hash
CURRENT_HASH=$(grep -oP 'hash = "sha256-\K[^"]+' flake.nix || echo "")
echo "Current hash: sha256-$CURRENT_HASH"
# Set temporary invalid hash to trigger error
sed -i 's/hash = "sha256-[^"]*";/hash = "sha256-AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=";/' flake.nix
# Build and capture the correct hash from error message
NEW_HASH=$(nix build .# 2>&1 | grep "got:" | awk '{print $2}' | sed 's/sha256-//' || echo "")
if [ -z "$NEW_HASH" ]; then
echo "Failed to get new hash, hash may already be correct"
git checkout flake.nix
echo "hash_changed=false" >> $GITHUB_OUTPUT
exit 0
fi
# Update with correct hash
sed -i "s/hash = \"sha256-[^\"]*\";/hash = \"sha256-$NEW_HASH\";/" flake.nix
if [ "$CURRENT_HASH" = "$NEW_HASH" ]; then
echo "Hash unchanged"
echo "hash_changed=false" >> $GITHUB_OUTPUT
else
echo "Hash updated from sha256-$CURRENT_HASH to sha256-$NEW_HASH"
echo "hash_changed=true" >> $GITHUB_OUTPUT
echo "new_hash=sha256-$NEW_HASH" >> $GITHUB_OUTPUT
fi
- name: Commit and push if changed
if: steps.update-hash.outputs.hash_changed == 'true'
run: |
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
git add flake.nix
git commit -m "chore(nix): update dependencies hash to ${{ steps.update-hash.outputs.new_hash }}"
git push