Skip to content

Commit

Permalink
Only process folders that have changes
Browse files Browse the repository at this point in the history
  • Loading branch information
gaby authored Nov 16, 2023
1 parent 6b7bed5 commit da12c55
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions .github/workflows/golangci-lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,17 @@ jobs:
uses: actions/checkout@v4
- id: set-matrix
run: |
DIRECTORIES=$(find . -type d -not -path '*/\.*' | jq -R -s -c 'split("\n")[:-1]')
echo "matrix=${DIRECTORIES}" >> $GITHUB_OUTPUT
# Get list of changed files
if [[ ${{ github.event_name }} == 'pull_request' ]]; then
FILES=$(git diff --name-only ${{ github.event.pull_request.base.sha }} ${{ github.sha }})
else
FILES=$(git diff --name-only ${{ github.event.before }} ${{ github.event.after }})
fi
# Extract directories from changed files, convert to JSON and export
DIRECTORIES=$(echo "$FILES" | xargs -L1 dirname | sort -u)
JSON_ARRAY=$(echo "$DIRECTORIES" | jq -R -s -c 'split("\n")[:-1]')
echo "matrix=${JSON_ARRAY}" >> $GITHUB_OUTPUT
lint:
needs: generate-matrix
Expand Down

0 comments on commit da12c55

Please sign in to comment.