Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prettier throws errors on PRs opened from forks #2294

Closed
spectranaut opened this issue Jul 25, 2024 · 4 comments · Fixed by #2307
Closed

Prettier throws errors on PRs opened from forks #2294

spectranaut opened this issue Jul 25, 2024 · 4 comments · Fixed by #2307
Assignees
Labels
Agenda-Editors editorial a change to an example, note, spelling, grammar, or is related to publishing or the repo

Comments

@spectranaut
Copy link
Contributor

See: #2290

@spectranaut spectranaut added editorial a change to an example, note, spelling, grammar, or is related to publishing or the repo Agenda-Editors labels Jul 25, 2024
@pkra
Copy link
Member

pkra commented Jul 26, 2024

This appears to be a limitation of github actions (of this type) according to creyD/prettier_action#54 (comment) (and the link from there).

@spectranaut
Copy link
Contributor Author

Do we need some kind of requirement for people who open PRs against ARIA from different repos to run prettier locally on their branch?

@smockle
Copy link
Contributor

smockle commented Aug 1, 2024

I ran into this too, in #2271 (comment).

The error is happening in the checkout step (not the prettier step), because github.head_ref (.github/workflows/prettier.yaml#L19) is the fork’s branch name, which won’t exist in this repo.

We could revise the checkout step like this—

uses: actions/checkout@v4
with:
  ref: ${{github.event.pull_request.head.ref}}
  repository: ${{github.event.pull_request.head.repo.full_name}}
  fetch-depth: 0

—that’d get us further, but we’d hit another problem: permissions. The default token used in w3c/aria’s workflow doesn’t have permissions to write (i.e. push commits) to random other repos (even forks).

There’s a two-part solution to that:

  1. The fork’s owner (presumably, the PR author) needs to “allow edits and access to secrets by maintainers”.1

  2. We need to run the workflow using a bot account’s token, and that bot account needs to have “Write” access to this repo.

Footnotes

  1. Optionally, we can add a comment to PRs if the author hasn’t done this. Homebrew does this, via .github/workflows/publish-commit-bottles.yml#L45-L47.

@daniel-montalvo
Copy link
Contributor

Thanks much @smockle for your detailed explanation.
I'll take a look at this.

I would prefer for The fork’s owner (presumably, the PR author) to “allow edits and access to secrets by maintainers”. We don't currently have a bot account set up.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Agenda-Editors editorial a change to an example, note, spelling, grammar, or is related to publishing or the repo
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants