Skip to content

Commit

Permalink
Merge pull request #339 from epage/action
Browse files Browse the repository at this point in the history
fix: Don't require sudo
  • Loading branch information
epage committed May 22, 2023
2 parents 7cfe519 + 68fe13b commit c594826
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
1 change: 1 addition & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ runs:
run: $GITHUB_ACTION_PATH/action/entrypoint.sh
shell: bash
env:
INSTALL_DIR: .
INPUT_ARGS: ${{ inputs.args }}
INPUT_COMMITS: ${{ inputs.commits }}

Expand Down
19 changes: 13 additions & 6 deletions action/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,25 @@ log() {
echo -e "$1" >&2
}

_DEFAULT_INSTALL_DIR=${HOME}/bin
_INSTALL_DIR=${INSTALL_DIR:-${_DEFAULT_INSTALL_DIR}}
CMD_NAME="committed"
COMMAND="${_INSTALL_DIR}/${CMD_NAME}"

if [[ -z $(which ${CMD_NAME} 2>/dev/null) ]]; then
if [[ -z ${INPUT_COMMITS:-} ]]; then
log "'INPUT_COMMITS' is required"
exit 1
fi

if [[ ! -x ${COMMAND} ]]; then
VERSION=1.0.17
log "Downloading 'committed' v${VERSION}"
wget https://github.com/crate-ci/committed/releases/download/v${VERSION}/committed-v${VERSION}-x86_64-unknown-linux-musl.tar.gz
sudo tar -xzvf committed-v${VERSION}-x86_64-unknown-linux-musl.tar.gz -C /usr/local/bin ./committed
wget --progress=dot:mega https://github.com/crate-ci/committed/releases/download/v${VERSION}/committed-v${VERSION}-x86_64-unknown-linux-musl.tar.gz
mkdir -p ${_INSTALL_DIR}
tar -xzvf committed-v${VERSION}-x86_64-unknown-linux-musl.tar.gz -C ${_INSTALL_DIR} ./${CMD_NAME}
rm committed-v${VERSION}-x86_64-unknown-linux-musl.tar.gz
fi

COMMAND="${CMD_NAME}"

echo "Linting commits:"
git config --global --add safe.directory "$PWD"
git log --color=always --graph --oneline "${INPUT_COMMITS}" || true
Expand All @@ -28,4 +35,4 @@ echo ""
echo "If this fails, don't sweat it. We're trying to encourage clear communication and not hinder contributions."
echo "If it is a reasonable issue and you lack time or feel uncomfortable fixing it yourself,"
echo "let us know and we can mentor or fix it."
${COMMAND} --color=always $INPUT_ARGS "${INPUT_COMMITS}"
${COMMAND} --color=always ${INPUT_ARGS:-} "${INPUT_COMMITS}"

0 comments on commit c594826

Please sign in to comment.