From fc7f51746699c0dacd6a3c2a8f594a18c1726336 Mon Sep 17 00:00:00 2001 From: Ed Page Date: Thu, 16 Jun 2022 10:09:50 -0500 Subject: [PATCH] perf(action): Limit checked files to those changed --- docker/Dockerfile | 2 +- docker/entrypoint.sh | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/docker/Dockerfile b/docker/Dockerfile index 5122bc9..f94c3d3 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -1,7 +1,7 @@ FROM ubuntu:20.04 ARG VERSION=1.9.0 ENV VERSION=${VERSION} -RUN apt-get update && apt-get install -y wget +RUN apt-get update && apt-get install -y wget git RUN wget https://github.com/crate-ci/typos/releases/download/v${VERSION}/typos-v${VERSION}-x86_64-unknown-linux-musl.tar.gz && \ tar -xzvf typos-v${VERSION}-x86_64-unknown-linux-musl.tar.gz && \ mv typos /usr/local/bin diff --git a/docker/entrypoint.sh b/docker/entrypoint.sh index a5e0af4..8e16d3c 100755 --- a/docker/entrypoint.sh +++ b/docker/entrypoint.sh @@ -8,6 +8,15 @@ log() { CMD_NAME="typos" TARGET=${INPUT_FILES:-"."} +if [[ -n "${GITHUB_BASE_REF:-}" ]]; then + git config --global --add safe.directory /github/workspace + if git rev-parse --verify master 2>/dev/null ; then + log "Limiting checks to ${GITHUB_BASE_REF}...HEAD" + TARGET=$(git diff ${GITHUB_BASE_REF}...HEAD --name-only --diff-filter=AM -- ${TARGET}) + else + log "WARN: Not limiting checks to ${GITHUB_BASE_REF}...HEAD, ${GITHUB_BASE_REF} is not available" + fi +fi if [[ -z $(ls ${TARGET} 2>/dev/null) ]]; then log "ERROR: Input files (${TARGET}) not found"