Can't overwrite files on the branch with the action
See original GitHub issueDescribe the bug
My CI is set up to deploy pull requests to separate folders to allow previewing changes. I’ve run into an issue while trying to push subsequent commits onto a pull request branch that has already been deployed.
On the Prepare publishing assets step (this line of code) it is trying to copy the assets over the previously existing ones, and even though force
is set to true
while copying, it still fails with EEXIST: file already exists
.
This failure is (probably mistakenly) treated as a failure to check out a branch, which causes the action to try and create a new branch, which doesn’t work because the branch, in fact, exists.
To Reproduce
- Set up deploying on pull requests (workflow file here)
- Create a pull request and let it deploy
- Push more commits to the same branch
Expected behavior
The action should empty out the directory that stores files for this PR, then freshly copy over the new assets
Your YAML file
https://github.com/illright/attractions/blob/develop/.github/workflows/pr_demo.yml
Additional context
Here’s the link to the failed job logs: https://github.com/illright/attractions/runs/857251843?check_suite_focus=true
Issue Analytics
- State:
- Created 3 years ago
- Comments:8 (7 by maintainers)
Top GitHub Comments
Actually, there is a simple workaround. The failure is due to the GitHub’s Action toolkit’s unexpected behaviour with copying stuff.
io.cp
uses a custom implementation ofmkdirP
under the hood, which fails with an error when trying to create an existing directory.The workaround is to forcefully remove the file at
filePath
(if it happens to exist) right before doing the copy operation.It won’t achieve the desired behaviour fully, since the subdirectory of deployment will still contain old files that weren’t overwritten, but for most use cases this is going to be just fine, because the build should complete successfully.
This issue has been LOCKED because of it being resolved!
The issue has been fixed and is therefore considered resolved. If you still encounter this or it has changed, open a new issue instead of responding to solved ones.
<div align="right">Log | Bot Usage</div>