use ::debug:: for echo statements meant to show up on actions
This commit is contained in:
parent
1a611dc730
commit
721b6744bf
18
action.yml
18
action.yml
@ -17,28 +17,32 @@ runs:
|
||||
- shell: bash
|
||||
run: |
|
||||
SOCK_OWNER_GID=$(stat -c %g ${{ inputs.socket-path }})
|
||||
echo "${{ inputs.socket-path }} is owned by gid=$SOCK_OWNER_GID"
|
||||
echo "::debug:: ${{ inputs.socket-path }} is owned by gid=$SOCK_OWNER_GID"
|
||||
|
||||
RUNNING_AS_USER=$(whoami)
|
||||
echo "${{ running as user: $RUNNING_AS_USER }}"
|
||||
echo "::debug:: ${{ running as user: $RUNNING_AS_USER }}"
|
||||
|
||||
SUDO_PREFIX=""
|
||||
if [[ "$RUNNING_AS_USER" != "root" ]]; then
|
||||
echo "current user is not sudo, assuming sudo is required"
|
||||
echo "::debug:: current user is not sudo, assuming sudo is required"
|
||||
SUDO_PREFIX="sudo"
|
||||
fi
|
||||
|
||||
if getent group $SOCK_OWNER_GID | grep -q "$RUNNING_AS_USER"; then
|
||||
echo "User is already a member of $SOCK_OWNER_GID"
|
||||
echo "::debug:: User is already a member of $SOCK_OWNER_GID"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if grep -q -E ":$SOCK_OWNER_GID:" /etc/group; then
|
||||
echo "Group for gid=$SOCK_OWNER_GID already exists, adding user to it"
|
||||
echo "::debug:: Group for gid=$SOCK_OWNER_GID already exists, adding user to it"
|
||||
$SUDO_PREFIX usermod -aG $(getent group $SOCK_OWNER_GID | cut -d: -f1) $RUNNING_AS_USER
|
||||
exit 0
|
||||
fi
|
||||
|
||||
echo "Group for gid=$SOCK_OWNER_GID does not exist, creating workaround group: ${{ input.workaround-group }}
|
||||
$SUDO_PREFIX groupadd -g $SOCK_OWNER_GID ${{ input.workaround-group }} \
|
||||
echo "::debug:: Group for gid=$SOCK_OWNER_GID does not exist, creating workaround group: ${{ input.workaround-group }}"
|
||||
$SUDO_PREFIX groupadd -g $SOCK_OWNER_GID ${{ input.workaround-group }}
|
||||
echo "::debug:: Group for gid=$SOCK_OWNER_GID created"
|
||||
|
||||
echo "::debug:: Adding user to workaround group: ${{ input.workaround-group }}"
|
||||
$SUDO_PREFIX usermod -aG ${{ input.workaround-group }} $RUNNING_AS_USER
|
||||
echo "::debug:: Added user to workaround group"
|
||||
|
||||
Loading…
Reference in New Issue
Block a user