Skip to content

Commit

Permalink
Cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
gaby authored Nov 17, 2023
1 parent a707767 commit d8c4365
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions .github/workflows/golangci-lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,19 @@ jobs:
BASE_SHA="${{ github.event.pull_request.base.sha || github.event.before }}"
HEAD_SHA="${{ github.event.pull_request.head.sha || github.event.after }}"
# Extract changed directories that contain a go.mod file
GO_MOD_DIRECTORIES=$(git diff --name-only $BASE_SHA $HEAD_SHA | grep '/go.mod$' | xargs -L1 dirname | sort -u)
# Extract directories from changed files, only include those with go.mod files
GO_MOD_DIRECTORIES=()
FILES=$(git diff --name-only $BASE_SHA $HEAD_SHA | grep -vE '/\.')
DIRECTORIES=$(echo "$FILES" | xargs -L1 dirname | sort -u)
# Convert to JSON and export
JSON_ARRAY=$(echo "$GO_MOD_DIRECTORIES" | jq -R -s -c 'split("\n")[:-1]')
for dir in $DIRECTORIES; do
if [[ -f "$dir/go.mod" ]]; then
GO_MOD_DIRECTORIES+=("$dir")
fi
done
# Export the JSON array
JSON_ARRAY=$(printf '%s\n' "${GO_MOD_DIRECTORIES[@]}" | jq -R -s -c 'split("\n")[:-1]')
echo "matrix=${JSON_ARRAY}" >> $GITHUB_OUTPUT
lint:
Expand Down

0 comments on commit d8c4365

Please sign in to comment.