Skip to content

Commit 1df3c24

Browse files
Harden behavior if sudo is installed or not
1 parent 944b6ba commit 1df3c24

File tree

3 files changed

+9
-9
lines changed

3 files changed

+9
-9
lines changed

.github/workflows/reusable-build-coverage.yml

+3-3
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ jobs:
2626
- name: "Determine prerequisites"
2727
id: prereq
2828
run: |
29-
DEBIAN_FRONTEND=noninteractive apt update && apt upgrade -y
30-
apt install -y sudo apt-utils
29+
command -v sudo >/dev/null 2>&1 || (apt update && apt install -y sudo)
30+
DEBIAN_FRONTEND=noninteractive sudo apt update && sudo apt upgrade -y
3131
echo "need_node=$(command -v node >/dev/null 2>&1 && echo 0 || echo 1)" >> $GITHUB_OUTPUT
3232
3333
# needed for github actions, and only if a bare ubuntu image is used
@@ -38,7 +38,7 @@ jobs:
3838
# https://github.com/nektos/act/issues/973
3939
if: ${{ steps.prereq.outputs.need_node == '1' && env.ACT }}
4040
run: |
41-
apt install -y curl
41+
sudo apt install -y curl
4242
curl -sS https://webi.sh/node | sh
4343
echo ~/.local/opt/node/bin >> $GITHUB_PATH
4444

.github/workflows/reusable-pre-commit.yml

+3-3
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@ jobs:
3131
- name: "Determine prerequisites"
3232
id: prereq
3333
run: |
34-
DEBIAN_FRONTEND=noninteractive apt update && apt upgrade -y
35-
apt install -y sudo apt-utils
34+
command -v sudo >/dev/null 2>&1 || (apt update && apt install -y sudo)
35+
DEBIAN_FRONTEND=noninteractive sudo apt update && sudo apt upgrade -y
3636
echo "need_node=$(command -v node >/dev/null 2>&1 && echo 0 || echo 1)" >> $GITHUB_OUTPUT
3737
3838
# needed for github actions, and only if a bare ubuntu image is used
@@ -43,7 +43,7 @@ jobs:
4343
# https://github.com/nektos/act/issues/973
4444
if: ${{ steps.prereq.outputs.need_node == '1' && env.ACT }}
4545
run: |
46-
apt install -y curl
46+
sudo apt install -y curl
4747
curl -sS https://webi.sh/node | sh
4848
echo ~/.local/opt/node/bin >> $GITHUB_PATH
4949

.github/workflows/reusable-ros-tooling-source-build.yml

+3-3
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,8 @@ jobs:
4141
- name: "Determine prerequisites"
4242
id: prereq
4343
run: |
44-
DEBIAN_FRONTEND=noninteractive apt update && apt upgrade -y
45-
apt install -y sudo apt-utils
44+
command -v sudo >/dev/null 2>&1 || (apt update && apt install -y sudo)
45+
DEBIAN_FRONTEND=noninteractive sudo apt update && sudo apt upgrade -y
4646
echo "need_node=$(command -v node >/dev/null 2>&1 && echo 0 || echo 1)" >> $GITHUB_OUTPUT
4747
4848
# needed for github actions, and only if a bare ubuntu image is used
@@ -53,7 +53,7 @@ jobs:
5353
# https://github.com/nektos/act/issues/973
5454
if: ${{ steps.prereq.outputs.need_node == '1' && env.ACT }}
5555
run: |
56-
apt install -y curl
56+
sudo apt install -y curl
5757
curl -sS https://webi.sh/node | sh
5858
echo ~/.local/opt/node/bin >> $GITHUB_PATH
5959

0 commit comments

Comments
 (0)