name: 'check-changes' description: 'Checks for file changes in a specified path.' inputs: base-commit: description: 'The commit hash to compare against. If not provided, the action will use HEAD^.' default: 'HEAD^' paths: description: 'A comma-separated list of file paths to check for changes. If any of these paths has changed files, the action will return true.' default: '' outputs: has-changes: description: 'Indicates whether there are changes in the specified paths.' value: ${{ steps.check.outputs.has-changes }} runs: using: 'composite' steps: - name: Check changes id: check shell: bash run: | hasChanges=false baseCommit='${{ inputs.base-commit }}' if [ "$baseCommit" = "0000000000000000000000000000000000000000" ]; then echo "Base commit is zero hash (merge commit or new branch). Define as always has changes." hasChanges=true fi if [ $hasChanges = false ]; then IFS=',' read -r -a paths <<< "${{ inputs.paths }}" diff=$(git diff --name-only $baseCommit HEAD) while IFS= read -r line; do for path in "${paths[@]}"; do if [[ $line == $path* ]]; then hasChanges=true break 2 fi done done <<< "$diff" fi echo "OUT: has-changes=$hasChanges" echo "has-changes=$hasChanges" >> $GITHUB_OUTPUT