DiamondLightSource / python3-pip-skeleton

Archived in favour of https://github.com/DiamondLightSource/python-copier-template
Apache License 2.0
4 stars 4 forks source link

Skip gh pages publishing for forks? #136

Open evalott100 opened 1 year ago

evalott100 commented 1 year ago

When a skeleton repo is forked, gh pages publishing will inevitably fail unless the org/user sets up their own docs pages:

  fatal: unable to access 'https://github.com/evalott100/event-model.git/': The requested URL returned error: 403
  Error: Action failed with "The process '/usr/bin/git' failed with exit code 128"

This isn't a huge problem since on a PR to the upstream repo the correct org will be used and doc publishing can be seen to be working before a merge. Though... might be worth skipping this step for forked repos, or fixing it so the upstream org is used? @gilesknap @coretl

coretl commented 1 year ago

Interesting, I was under the impression that you could always push to the gh-pages branch of your own fork. Maybe it's not trying to do this. Do you have a link to the actions output that produced this?

evalott100 commented 1 year ago

@coretl

https://github.com/evalott100/event-model/actions/runs/5044101600/jobs/9046917635#step:10:196

I'm thinking this is probably a permission thing - setting up the bot incorrectly?

coretl commented 1 year ago

Surprising, public forks are given a read only token, so cannot write back to the fork: https://github.blog/changelog/2021-04-20-github-actions-control-permissions-for-github_token/

This doesn't seem intuitive, I can see why it shouldn't be able to write back to the original repo, but why can't it write to itself? Maybe this is something that #133 would fix for us if we worked out how to make it work with multiple versions...

@gilesknap @garryod any ideas?

gilesknap commented 1 year ago

@coretl my reading of that page is that the fork gets a read only token for actions fired by a pull request back to the original repo. The implication being that it has the usual permissions for its own actions.

I thought the issue Eva reports is just that gh-pages is not set up on the fork? #133 also needs settings in the glpages section of your repo to work so would not improve this.

coretl commented 1 year ago

The error in the logs is 403 when trying to push to the gh-pages of the fork. Given that https://github.com/evalott100/event-model/tree/gh-pages exists, I take this to mean it doesn't have permission...

gilesknap commented 1 year ago

hmmm. Mr. peaceiris himself claims that this does work using secrets.GITHUB_TOKEN https://github.com/peaceiris/actions-gh-pages/issues/153#issuecomment-598289743

But I tried it and first it failed to create the gh-pages branch, I manually added that, set the pages option up on that branch and then got the same as Eva:

Push the commit or tag
  /usr/bin/git push origin gh-pages
  remote: Permission to gilesknap/python3-pip-skeleton-cli.git denied to github-actions[bot].
  fatal: unable to access 'https://github.com/gilesknap/python3-pip-skeleton-cli.git/': The requested URL returned error: 403
  Error: Action failed with "The process '/usr/bin/git' failed with exit code 128"

Perhaps this has changed since March 2020?

coretl commented 1 year ago

Is this worth an issue on the actions-gh-pages repo?

coretl commented 1 year ago

Should skip publishing to gh-pages for a fork

coretl commented 1 year ago

If origin org is different from the fork org then skip publishing