The sample provides a bit dated code. I think using aws-actions/setup-sam@v2 would remove some boilerplate, and actions/checkout@v2 is also a bit dated - should be v4 at this point.
Using setup-sam would also imply having a samconfig.toml in the root.