doxygen-github-pages-action icon indicating copy to clipboard operation
doxygen-github-pages-action copied to clipboard

Permission to denied error when deploying

Open jhlegarreta opened this issue 2 years ago • 8 comments

Hi, thanks for developing and maintaining this tool.

I am trying to use it for a repository that I contribute to. So far, my effort has been unsuccessful. I am getting an

remote: Permission to SlicerDMRI/SlicerDMRI.git denied to github-actions[bot].
fatal: unable to access 'https://github.com/SlicerDMRI/SlicerDMRI.git/': The requested URL returned error: 403

error at the moment where the deployment should take place: https://github.com/SlicerDMRI/SlicerDMRI/actions/runs/6685911043/job/18164701923?pr=195#step:2:787

I have granted write permissions to the workflow, actions do have write permissions in the repository settings, and the GitHub pages Build and deployment is configured to deploy from the gh-pages branch; I have also tried setting it to GitHub Actions with the same result.

What am I missing?

Thanks.

jhlegarreta avatar Oct 29 '23 22:10 jhlegarreta

It seems like a default settings change with new repositories.

I think the read and write permissions configured at Settings > Actions > General at the bottom should allow it to work.

image

Another solution suggested at https://github.com/JamesIves/github-pages-deploy-action?tab=readme-ov-file#getting-started-airplane is to add this to the workflow:

permissions:
  contents: write

Looks like it could go between the on: and jobs: sections.

Let me know if this helps, if so it maybe that could be added to the readme example.

DenverCoder1 avatar Oct 29 '23 22:10 DenverCoder1

Thanks for the quick reply. I had already tried both suggestions to no avail.

jhlegarreta avatar Oct 29 '23 22:10 jhlegarreta

It may be because the workflow is being run in a different repository, default GitHub tokens created for workflows in forks may have limited permissions, though I'm not sure what can be done about that. I've only tested this as an "on push to main" workflow and as far as I can tell it is still working for that.

If I figure anything out, I'll let you know

DenverCoder1 avatar Oct 29 '23 22:10 DenverCoder1

Maybe not an ideal solution, but I suppose one way to test the workflow is by pushing it to the main/master branch of a fork.

DenverCoder1 avatar Oct 29 '23 22:10 DenverCoder1

It may be because the workflow is being run in a different repository, default GitHub tokens created for workflows in forks may have limited permissions, though I'm not sure what can be done about that.

OK. Sounds a reasonable explanation. As you are using the action https://github.com/JamesIves/github-pages-deploy-action/discussions/, maybe I can ask there to see if they have more insight? There are some related discussions there, all suggesting what you proposed, but as said, I had already tried those.

I've only tested this as an "on push to main" workflow and as far as I can tell it is still working for that.

I initially had that configuration, but was willing to know whether the workflow would work prior to merging the branch into main.

If I figure anything out, I'll let you know

Thanks. Although I know deploying from a branch/fork is not the desired behavior for a user, ideally, a maintainer (and a user) would like to see whether a given fix or enhancement to the documentation is working as expected prior to merging the branch that contains the fix or enhancement. I ignore whether this can be done.

jhlegarreta avatar Oct 29 '23 22:10 jhlegarreta

As you are using the action JamesIves/github-pages-deploy-action/discussions, maybe I can ask there to see if they have more insight?

Yeah, the action is a composite of 5 steps and the last step uses https://github.com/JamesIves/github-pages-deploy-action to push to the repository which is where it is failing. The doxygen-github-pages-action steps are listed in the readme and all in action.yml if you want to see how it works.

DenverCoder1 avatar Oct 29 '23 22:10 DenverCoder1

Maybe not an ideal solution, but I suppose one way to test the workflow is by pushing it to the main/master branch of a fork.

May look into that. Thanks for suggesting.

Yeah, the action is a composite of 5 steps and the last step uses https://github.com/JamesIves/github-pages-deploy-action to push to the repository which is where it is failing

Will post the question in the discussions in there, see what they say. Will report back if something relevant is said. Thanks.

jhlegarreta avatar Oct 29 '23 23:10 jhlegarreta

May look into that. Thanks for suggesting.

Did not work: it showed the README page.

The gh-pages branch contained the right content, with the index.html being the landing page for the Doxygen documentation: https://github.com/jhlegarreta/SlicerDMRI/tree/gh-pages

In the Settings of my fork, GitHub Pages/Build and deployment I had tried both options GitHub Actions and Deploy from a Branch (the branch being gh-pages) with the same result.

Just for the sake of trying it, I later created directly in GitHub another GHA workflow file this time using:

on:
  push:
    branches:
      - main

in the workflow file (using main was an oversight on my side -the repository uses master; I presume the deployment took place as I manually run the action), and it got deployed correctly (with poor documentation from the package for unrelated reasons):

gh_pages_doxygen_doc_crop

So it looks there is some issue with the action being used from a fork or the events triggering the action.

jhlegarreta avatar Oct 30 '23 23:10 jhlegarreta