From ec0ee87e6a8051b5427984e18c2033bbad527776 Mon Sep 17 00:00:00 2001 From: Ahmad Husen Date: Sun, 30 May 2021 13:52:20 +0700 Subject: [PATCH] feat(bash): run all commmand with non-root user --- Dockerfile | 2 +- entrypoint.sh | 18 +++++------------- 2 files changed, 6 insertions(+), 14 deletions(-) diff --git a/Dockerfile b/Dockerfile index 90f43bb..b91dc2c 100644 --- a/Dockerfile +++ b/Dockerfile @@ -2,7 +2,7 @@ FROM docker.io/library/archlinux:base-devel # Install dependencies -RUN pacman -Syu --needed --noconfirm pacman-contrib namcap git rsync +RUN pacman -Syu --needed --noconfirm pacman-contrib namcap git # Setup user RUN useradd --create-home --shell /bin/bash builder && \ diff --git a/entrypoint.sh b/entrypoint.sh index 0daea1c..52d1104 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -1,18 +1,15 @@ #!/bin/bash # Set path -echo '::group::Copying $WORKPATH to /tmp/gh-action' -WORKPATH=$GITHUB_WORKSPACE/$INPUT_PATH -# Set path permision -sudo -u builder cp -rfv $WORKPATH /tmp/gh-action -cd /tmp/gh-action +echo '::group::Changing directory to $PATH' +cd ./$INPUT_PATH echo '::endgroup::' # Update checksums echo '::group::Updating checksums on PKGBUILD' if [[ $INPUT_UPDPKGSUMS == true ]]; then sudo -u builder updpkgsums - git diff PKGBUILD + sudo -u builder git diff PKGBUILD fi echo '::endgroup::' @@ -20,14 +17,14 @@ echo '::endgroup::' echo '::group::Generating new .SRCINFO based on PKGBUILD' if [[ $INPUT_SRCINFO == true ]]; then sudo -u builder makepkg --printsrcinfo > .SRCINFO - git diff .SRCINFO + sudo -u builder git diff .SRCINFO fi echo '::endgroup::' # Validate with namcap echo '::group::Validating PKGBUILD with namcap' if [[ $INPUT_NAMCAP == true ]]; then - namcap -i PKGBUILD + sudo -u builder namcap -i PKGBUILD fi echo '::endgroup::' @@ -37,8 +34,3 @@ if [[ -n "$INPUT_FLAGS" ]]; then sudo -u builder makepkg $INPUT_FLAGS fi echo '::endgroup::' - -echo '::group::Copying /tmp/gh-action to $WORKPATH' -rsync -avh --delete /tmp/gh-action/ $WORKPATH/ -cd $WORKPATH -echo '::endgroup::'