Skip to content

Commit 1120562

Browse files
refactor: Improve lockfile regeneration in Dependabot PR workflow by distinguishing between yarn and npm projects and ensuring proper git add for lockfiles
1 parent 70bfb0a commit 1120562

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

.github/workflows/group-dependabot-security-updates.yml

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -224,15 +224,22 @@ jobs:
224224
case "$group_name" in
225225
frontend)
226226
if [ -f "package.json" ]; then
227-
if grep -q '"workspaces":' package.json || [ -f "yarn.lock" ]; then
228-
echo "Running 'yarn install' to regenerate lockfile."
227+
# If a yarn.lock file exists, we treat it as a yarn project.
228+
if [ -f "yarn.lock" ]; then
229+
echo "Found yarn.lock, running 'yarn install' to regenerate lockfile."
229230
yarn install --ignore-scripts
231+
git add package.json yarn.lock
232+
# Otherwise, we fall back to npm.
230233
else
231-
echo "Running 'npm install' to regenerate lockfile."
234+
echo "No yarn.lock found. Running 'npm install' to regenerate lockfile."
232235
npm install --ignore-scripts
236+
git add package.json
237+
# Add package-lock.json only if it exists.
238+
if [ -f "package-lock.json" ]; then
239+
git add package-lock.json
240+
fi
233241
fi
234242
fi
235-
git add yarn.lock package-lock.json package.json
236243
;;
237244
backend)
238245
echo "Running 'pip install' to update dependencies."

0 commit comments

Comments
 (0)