Cancelling previous workflow runs if a newer one is started

name: Example CI
 
on:
  push:
    branches:
      - main
  pull_request:
    branches:
      - main
 
#...
concurrency:
  group: ${{ github.workflow }}-${{ github.ref }}
  cancel-in-progress: true
#...
 
jobs:
#...