NCEAS / metacatui

MetacatUI: A client-side web interface for DataONE data repositories
https://nceas.github.io/metacatui
Apache License 2.0
42 stars 24 forks source link

Github Actions: Reviewdog error with Prettier #2451

Open robyngit opened 2 weeks ago

robyngit commented 2 weeks ago

The reviewdog with prettier action to check formatting on PRs isn't working as expected. The action details show the following problem:

📝 Running prettier with reviewdog 🐶 ...
  reviewdog: This GitHub token doesn't have write permission of Review API [1], 
  so reviewdog will report results via logging command [2] and create annotations similar to
  github-pr-check reporter as a fallback.
  [1]: https://docs.github.com/en/actions/reference/events-that-trigger-workflows#pull_request_target, 
  [2]: https://help.github.com/en/actions/automating-your-workflow-with-github-actions/development-tools-for-github-actions#logging-commands

Here is a job run with the error: https://github.com/NCEAS/metacatui/actions/runs/9556159324/job/26377186438

We need to configure the permissions for the job properly. We currently have the following set:

    permissions:
      contents: read
      pull-requests: write 

I'm not sure why this doesn't work, this will need some further investigation.

robyngit commented 2 weeks ago

I think this may be a security feature of GitHub actions. When workflows run on pull_request events triggered by forks, GitHub restricts the permissions of the GITHUB_TOKEN to prevent potential misuse of secrets or repository access by untrusted code. This PR was in fact a fork, so I think that could be the source of the error.

We might need to conditionally run a different step for PRs that are from forks?