ackama / rails-template

Application template for Rails 7 projects; preloaded with best practices for TDD, security, deployment, and developer productivity.
Other
294 stars 15 forks source link

ci: explicitly define permissions for each job and as the first property in each job #513

Closed G-Rath closed 9 months ago

G-Rath commented 9 months ago

In my mind there's a number of advantages to this:

Note that our reusable workflows do still have a workflow-level permissions property - I've kept this because reusable workflows can only narrow permissions meaning the caller job should still always have a permissions block, and so in my mind for reusable workflows permissions is more "here's what you need to copy into the caller job" which would be more work if we were to have a reusable workflow with multiple jobs that had different permissions as you'd have to manually do the work of merging.

On the other hand they arguably muddy our "don't use global permissions" message so happy to refactor them to be per-job as well if people don't think it'll be a problem.

Also note that while we can and should configure the default permissions at the repository level, we still want to explicitly set the permissions in each workflow because we can't be sure the permissions are tightened at the repository level and this only costs us a couple of bytes in lines of code so there's no real downside 🤷