Skip to content

Commit

Permalink
feat(action): automatically update package-lock.json and npmDepsHash …
Browse files Browse the repository at this point in the history
…on package.json changed
  • Loading branch information
aimixsaka committed Jul 26, 2024
1 parent 1aafc65 commit 3de6c86
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 0 deletions.
32 changes: 32 additions & 0 deletions .github/workflows/udpate-nix-npm-dep.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: automatically update package-lock.json and npmDepsHash

on:
push:
branches: ["master"]

jobs:
update:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- name: check if package.json has changed
run: |
if ! git diff --name-only HEAD HEAD~ | grep package.json; then
exit 0
fi
- name: update package-lock.json and npmDepsHash
uses: cachix/install-nix-action@v27
uses: actions/setup-node@v4
run: ./update-nix-npm-dep.sh

- name: create github pr
uses: peter-evans/create-pull-request@v6
with:
token: ${{ secrets.ACTION_TOKEN }}
commit-message: bump package-lock.json and flake npmDepsHash
branch: auto-update/nix-npm
branch-suffix: short-commit-hash
delete-branch: true
title: '[Nix Npm Bump] Update package-lock.json and flake npmDepsHash'
5 changes: 5 additions & 0 deletions update-nix-npm-dep.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/usr/bin/env bash

# script help to update package-lock.json and nix flake npmDepsHash
npm i --package-lock-only
sed -i "s|npmDepsHash = \".*\";|npmDepsHash = \"$(nix run nixpkgs#prefetch-npm-deps package-lock.json | tail -1)\";|" flake.nix

0 comments on commit 3de6c86

Please sign in to comment.