When I push my commits to a PR my tests are triggered for this commit. After that, if I push additional commits to this PR, tests in Github Actions runs on both commits.
I need to cancel the previous run and run only on the most recent pushed commit.
How can I configure my yaml file to achieve that?
You can use Concurrency:
Concurrency ensures that only a single job or workflow using the same concurrency group will run at a time.
concurrency:
group: ${{ github.head_ref }}
cancel-in-progress: true