10000 Fix workflow to update dependencies · github/codeql-action@cf1855a · GitHub
[go: up one dir, main page]

Skip to content

Commit cf1855a

Browse files
committed
Fix workflow to update dependencies
Port over the fix from #1544 and share code so these scripts don't get out of sync again.
1 parent 237a258 commit cf1855a

File tree

3 files changed

+20
-15
lines changed

3 files changed

+20
-15
lines changed

.github/workflows/script/check-node-modules.sh

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,9 @@ if [ ! -z "$(git status --porcelain)" ]; then
77
>&2 echo "Failed: Repo should be clean before testing!"
88
exit 1
99
fi
10-
# When updating this, make sure to update the npm version in
11-
# `.github/workflows/update-dependencies.yml` too.
12-
sudo npm install --force -g npm@9.2.0
1310

14-
# clean the npm cache to ensure we don't have any files owned by root
15-
sudo npm cache clean --force
11+
"$(dirname "$0")/update-node-modules.sh" check-only
1612

17-
# Reinstall modules and then clean to remove absolute paths
18-
# Use 'npm ci' instead of 'npm install' as this is intended to be reproducible
19-
npm ci
20-
npm run removeNPMAbsolutePaths
2113
# Check that repo is still clean
2214
if [ ! -z "$(git status --porcelain)" ]; then
2315
# If we get a fail here then the PR needs attention
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
if [ "$1" != "update" && "$1" != "check-only" ]; then
2+
>&2 echo "Failed: Invalid argument. Must be 'update' or 'check-only'"
3+
exit 1
4+
fi
5+
6+
sudo npm install --force -g npm@9.2.0
7+
8+
# clean the npm cache to ensure we don't have any files owned by root
9+
sudo npm cache clean --force
10+
11+
if [ "$1" = "update" ]; then
12+
npm install
13+
fi
14+
15+
# Reinstall modules and then clean to remove absolute paths
16+
# Use 'npm ci' instead of 'npm install' as this is intended to be reproducible
17+
npm ci
18+
npm run removeNPMAbsolutePaths

.github/workflows/update-dependencies.yml

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,7 @@ jobs:
2727
run: |
2828
git fetch origin "$BRANCH" --depth=1
2929
git checkout "origin/$BRANCH"
30-
# When updating this, make sure to update the npm version in
31-
# `.github/workflows/script/check-node-modules.sh` too.
32-
sudo npm install --force -g npm@9.2.0
33-
npm install
34-
npm ci
35-
npm run removeNPMAbsolutePaths
30+
.github/workflows/script/update-node-modules.sh update
3631
if [ ! -z "$(git status --porcelain)" ]; then
3732
git config --global user.email "github-actions@github.com"
3833
git config --global user.name "github-actions[bot]"

0 commit comments

Comments
 (0)
0