Skip to content

Commit

Permalink
Filter for dirs that contain go.mod
Browse files Browse the repository at this point in the history
  • Loading branch information
gaby authored Nov 16, 2023
1 parent 38f87f3 commit 58fa288
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions .github/workflows/golangci-lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,11 @@ jobs:
HEAD_SHA="${{ github.event.after }}"
fi
# Extract directories from changed files, exclude hidden directories, convert to JSON and export
FILES=$(git diff --name-only $BASE_SHA $HEAD_SHA)
DIRECTORIES=$(echo "$FILES" | xargs -L1 dirname | grep -vE '^\./\.' | sort -u)
JSON_ARRAY=$(echo "$DIRECTORIES" | jq -R -s -c 'split("\n")[:-1]')
# Find changed directories that contain go.mod, convert to JSON and export
GO_MOD_DIRECTORIES=$(find . -name 'go.mod' | xargs -L1 dirname | sort -u)
CHANGED_DIRECTORIES=$(echo "$FILES" | xargs -L1 dirname | sort -u)
MATCHED_DIRECTORIES=$(echo "${GO_MOD_DIRECTORIES}" "${CHANGED_DIRECTORIES}" | tr ' ' '\n' | sort | uniq -d)
JSON_ARRAY=$(echo "$MATCHED_DIRECTORIES" | jq -R -s -c 'split("\n")[:-1]')
echo "matrix=${JSON_ARRAY}" >> $GITHUB_OUTPUT
lint:
Expand Down

0 comments on commit 58fa288

Please sign in to comment.