How can I run Linter only on changed files?

You can do that by using one of the existing actions in the Marketplace.

https://github.com/tj-actions/changed-files

And the pass the output of this to your linter.

You can also play with git log to get those files, but to cover all cases in PRs, branches etc... it's getting really complicated so it doesn't make sense to reinvent the wheel imho.