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

error: failed to delete github-pages-deploy-action-temp-deployment-folder: Permission denied #922

Closed
tobiasBora opened this issue Nov 9, 2021 · 12 comments · Fixed by #925
Labels
bug 🐦 Something isn't working version 4 Issues related to version 4 of this action.
Milestone

Comments

@tobiasBora
Copy link

Describe the bug

Once my website is pushed on the gh-pages branch, the script fails with:

error: failed to delete '/home/runner/work/website/website/github-pages-deploy-action-temp-deployment-folder': Permission denied

Reproduction Steps

I just tried to build my website using this workflow https://github.com/leo-colisson/website/runs/4154643484?check_suite_focus=true

Logs

Run JamesIves/github-pages-deploy-action@4.1.5

    GitHub Pages Deploy Action 🚀

    🚀 Getting Started Guide: https://github.com/marketplace/actions/deploy-to-github-pages
    ❓ Discussions / Q&A: https://github.com/JamesIves/github-pages-deploy-action/discussions
    🔧 Report a Bug: https://github.com/JamesIves/github-pages-deploy-action/issues

    📣 Maintained by James Ives: https://jamesiv.es
    💖 Support: https://github.com/sponsors/JamesIves
Checking configuration and starting deployment… 🚦
Deploying using Deploy Token… 🔑
Configuring git…
/usr/bin/git config user.name tobiasBora
/usr/bin/git config user.email tobias.bora@gmail.com
/usr/bin/git config --local --unset-all http.https://github.com/.extraheader
/usr/bin/git remote rm origin
/usr/bin/git remote add origin ***github.com/leo-colisson/website.git
Git configured… 🔧
Starting to commit changes…
/usr/bin/git ls-remote --heads ***github.com/leo-colisson/website.git refs/heads/gh-pages
Creating worktree…
/usr/bin/git worktree add --no-checkout --detach github-pages-deploy-action-temp-deployment-folder
Preparing worktree (detached HEAD 6fe0d2e)
/usr/bin/git checkout --orphan gh-pages
Switched to a new branch 'gh-pages'
Created the gh-pages branch… 🔧
/usr/bin/git reset --hard
/usr/bin/git commit --no-verify --allow-empty -m Initial gh-pages commit
[gh-pages (root-commit) 2c24bad] Initial gh-pages commit
/usr/bin/rsync -q -av --checksum --progress /home/runner/work/website/website/result/. github-pages-deploy-action-temp-deployment-folder --delete --exclude CNAME --exclude .nojekyll --exclude .ssh --exclude .git --exclude .github
Checking if there are files to commit…
/usr/bin/git add --all .
/usr/bin/git checkout -b github-pages-deploy-action/6kdalw7oq
Switched to a new branch 'github-pages-deploy-action/6kdalw7oq'
/usr/bin/git commit -m Deploying to gh-pages from @ leo-colisson/website@6fe0d2e04ef365633842f4f9ccf326bf84867452 🚀 --quiet --no-verify
/usr/bin/git push --force ***github.com/leo-colisson/website.git github-pages-deploy-action/6kdalw7oq:gh-pages
remote: 
remote: Create a pull request for 'gh-pages' on GitHub by visiting:        
remote:      https://github.com/leo-colisson/website/pull/new/gh-pages        
remote: 
To https://github.com/leo-colisson/website.git
 * [new branch]      github-pages-deploy-action/6kdalw7oq -> gh-pages
Changes committed to the gh-pages branch… 📦
Running post deployment cleanup jobs… 🗑️
/usr/bin/git checkout -B github-pages-deploy-action/6kdalw7oq
Reset branch 'github-pages-deploy-action/6kdalw7oq'
/usr/bin/git worktree remove github-pages-deploy-action-temp-deployment-folder --force
error: failed to delete '/home/runner/work/website/website/github-pages-deploy-action-temp-deployment-folder': Permission denied
Error: The process '/usr/bin/git' failed with exit code 255
Deployment failed! ❌
@JamesIves
Copy link
Owner

Can you provide your workflow yml?

@tobiasBora
Copy link
Author

@JamesIves
Copy link
Owner

You probably need to provide the action with a personal access token with the required set of scoped permissions or an SSH key. This issue is likely stemming from a lack of permissions that the default GitHub token doesn't provide to organization accounts.

If you take a look at the readme there's a section on the token parameter which should be able to help you.

@JamesIves JamesIves added support ❓ Issues related to action support. and removed triage ⚠️ labels Nov 12, 2021
@autophagy
Copy link

I'm also encountering this issue. An example run where this fails (https://github.com/autophagy/tid/runs/4193315329?check_suite_focus=true#step:5:47):

Run JamesIves/github-pages-deploy-action@4.1.5
  with:
    branch: gh-pages
    folder: result
    token: ***
    clean: false

    GitHub Pages Deploy Action 🚀

    🚀 Getting Started Guide: https://github.com/marketplace/actions/deploy-to-github-pages
    ❓ Discussions / Q&A: https://github.com/JamesIves/github-pages-deploy-action/discussions
    🔧 Report a Bug: https://github.com/JamesIves/github-pages-deploy-action/issues

    📣 Maintained by James Ives: https://jamesiv.es
    💖 Support: https://github.com/sponsors/JamesIves
Checking configuration and starting deployment… 🚦
Deploying using Deploy Token… 🔑
Configuring git…
/usr/bin/git config user.name autophagy
/usr/bin/git config user.email mail@autophagy.io
/usr/bin/git config --local --unset-all http.https://github.com/.extraheader
/usr/bin/git remote rm origin
/usr/bin/git remote add origin ***github.com/autophagy/tid.git
Git configured… 🔧
Starting to commit changes…
/usr/bin/git ls-remote --heads ***github.com/autophagy/tid.git refs/heads/gh-pages
644f05cfdc4919c2aac3db1257d9adda36c53ca1	refs/heads/gh-pages
Creating worktree…
/usr/bin/git fetch --no-recurse-submodules --depth=1 origin gh-pages
From https://github.com/autophagy/tid
 * branch            gh-pages   -> FETCH_HEAD
 * [new branch]      gh-pages   -> origin/gh-pages
/usr/bin/git worktree add --no-checkout --detach github-pages-deploy-action-temp-deployment-folder
Preparing worktree (detached HEAD 6263e59)
/usr/bin/git checkout -B gh-pages origin/gh-pages
Previous HEAD position was 6263e59 Use GHP token and dont clean when deploying
Switched to a new branch 'gh-pages'
Branch 'gh-pages' set up to track remote branch 'gh-pages' from 'origin'.
/usr/bin/rsync -q -av --checksum --progress /home/runner/work/tid/tid/result/. github-pages-deploy-action-temp-deployment-folder --exclude .ssh --exclude .git --exclude .github
Checking if there are files to commit…
Running post deployment cleanup jobs… 🗑️
/usr/bin/git checkout -B github-pages-deploy-action/ere51deps
Switched to a new branch 'github-pages-deploy-action/ere51deps'
/usr/bin/git worktree remove github-pages-deploy-action-temp-deployment-folder --force
error: failed to delete '/home/runner/work/tid/tid/github-pages-deploy-action-temp-deployment-folder': Permission denied
Error: The process '/usr/bin/git' failed with exit code 255
Deployment failed! ❌

The workflow used for this run was https://github.com/autophagy/tid/actions/runs/1454300841/workflow

For this particular run, I had given it a token that had all permissions a PAT could have. It creates and pushes the commit perfectly fine, it's just the step where it attempts to remove github-pages-deploy-action-temp-deployment-folder from the worktree where it fails.

@JamesIves
Copy link
Owner

JamesIves commented Nov 12, 2021

@autophagy In your case what happens when you remove the token parameter? I tried a PAT in a test repo of mine and it seems to have passed so I'm wondering if there's something else that could be causing these permission issues 🤔

Oddly enough it does seem that both workflows are using nix. It makes me wonder if something in that workflow step is altering the permissions of the git process.

@autophagy
Copy link

@JamesIves Without the token parameter, I got the same result: error: failed to delete '/home/runner/work/tid/tid/github-pages-deploy-action-temp-deployment-folder': Permission denied.

Yeah, it's possible that some nix-weirdness might be at play here, I wasn't able to reproduce it with a non-nix based build workflow.

@tobiasBora
Copy link
Author

tobiasBora commented Nov 15, 2021 via email

@JamesIves
Copy link
Owner

I'll give this a shot tomorrow morning and see if I can replicate this bug. I have some ideas on how this can be resolved.

@JamesIves JamesIves added bug 🐦 Something isn't working version 4 Issues related to version 4 of this action. and removed support ❓ Issues related to action support. labels Nov 17, 2021
@JamesIves
Copy link
Owner

Good morning;

@autophagy & @tobiasBora, do you mind pointing your actions to uses: JamesIves/github-pages-deploy-action@releases/v4-folder-perms? I just finished testing this on a fork of one of the provided repos in this issue and I believe I've found a fix for this, but would be good to get some more eyes on it before I push it into the next release.

@JamesIves JamesIves added this to the 4.1.6 milestone Nov 17, 2021
@JamesIves
Copy link
Owner

This has been released as part of version 4.1.6.

@autophagy
Copy link

@JamesIves Can confirm that this works for me now. Thank you a ton! ✨

tobiasBora added a commit to leo-colisson/website that referenced this issue Nov 20, 2021
@tobiasBora
Copy link
Author

Sorry, I had no time to check it before, but I confirm it works greatly, thanks a lot!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 🐦 Something isn't working version 4 Issues related to version 4 of this action.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants