From bfab7743f6dbaa170f1eb9b43807af80f041ba8c Mon Sep 17 00:00:00 2001 From: Collie Tsai Date: Thu, 20 Feb 2025 07:13:35 +0800 Subject: [PATCH] fix sudo issue on ubuntu --- .github/workflows/test-distros.yaml | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/.github/workflows/test-distros.yaml b/.github/workflows/test-distros.yaml index d62e165..e2ba0e7 100644 --- a/.github/workflows/test-distros.yaml +++ b/.github/workflows/test-distros.yaml @@ -28,16 +28,21 @@ jobs: - name: Prepare environment run: | if command -v apt-get >/dev/null; then - sudo apt-get update - sudo apt-get install -y sudo git curl + if [ "$(id -u)" = "0" ]; then + apt-get update + apt-get install -y sudo git curl + else + sudo apt-get update + sudo apt-get install -y sudo git curl + fi if ! command -v chezmoi >/dev/null; then sh -c "$(curl -fsLS get.chezmoi.io)" -- -b /usr/local/bin fi elif command -v pacman >/dev/null; then - if ! command -v sudo > /dev/null; then + if ! command -v sudo >/dev/null; then pacman -Syu --noconfirm sudo fi - sudo pacman -Syu --noconfirm git chezmoi + sudo pacman -Syu --noconfirm git chezmoi curl else exit 1 fi @@ -45,4 +50,8 @@ jobs: echo "dev ALL=(ALL) NOPASSWD: ALL" | sudo tee /etc/sudoers.d/dev - name: chezmoi init dotfiles run: | - sudo -u dev chezmoi init --apply collieiscute -v + if command -v sudo >/dev/null; then + sudo -u dev chezmoi init --apply collieiscute -v + else + su dev -c 'chezmoi init --apply collieiscute -v' + fi