Skip to content

Commit 56f4e60

Browse files
Work around 'npm run ...' executing as different user
Signed-off-by: Christophe Bedard <bedard.christophe@gmail.com>
1 parent 2f26955 commit 56f4e60

1 file changed

Lines changed: 12 additions & 0 deletions

File tree

.github/workflows/build-and-test.sh

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,18 @@ set -euxo pipefail
33

44
npm install -g codecov
55

6+
# When running inside a Docker container, by default, we're root and all files belond to root.
7+
# However, calling the npm scripts (build, etc.) with 'npm run ...' runs the commands as user
8+
# ID=1001, which means we can't open or write to any files. Therefore, if we're in Docker, chown
9+
# everything under /__w (which is the workspace directory on the host: /home/runner/work) to user
10+
# ID=1001. See:
11+
# * https://github.com/ros-tooling/setup-ros/pull/521
12+
# * https://github.com/npm/cli/issues/4589
13+
docker_workdir="/__w"
14+
if [ -d "${docker_workdir}" ]; then
15+
chown -R 1001:1001 "${docker_workdir}"
16+
fi
17+
618
npm ci
719
npm run build
820
npm test

0 commit comments

Comments
 (0)