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

Permission to denied error when deploying #24

Open
jhlegarreta opened this issue Oct 29, 2023 · 8 comments
Open

Permission to denied error when deploying #24

jhlegarreta opened this issue Oct 29, 2023 · 8 comments

Comments

@jhlegarreta
Copy link

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.

@DenverCoder1
Copy link
Owner

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.

@jhlegarreta
Copy link
Author

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

@DenverCoder1
Copy link
Owner

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
Copy link
Owner

DenverCoder1 commented Oct 29, 2023

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.

@jhlegarreta
Copy link
Author

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.

@DenverCoder1
Copy link
Owner

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.

@jhlegarreta
Copy link
Author

jhlegarreta commented Oct 29, 2023

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
Copy link
Author

jhlegarreta commented Oct 30, 2023

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants