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

Can't overwrite files on the branch with the action #390

Closed
illright opened this issue Jul 10, 2020 · 8 comments
Closed

Can't overwrite files on the branch with the action #390

illright opened this issue Jul 10, 2020 · 8 comments
Assignees
Labels

Comments

@illright
Copy link

Describe 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

  1. Set up deploying on pull requests (workflow file here)
  2. Create a pull request and let it deploy
  3. 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

@illright illright added the bug Something isn't working label Jul 10, 2020
@peaceiris
Copy link
Owner

Now, this use case is not supported.
Related to #324

@peaceiris peaceiris added enhancement New feature or request proposal and removed bug Something isn't working labels Jul 10, 2020
@illright
Copy link
Author

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 of mkdirP 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.

@peaceiris
Copy link
Owner

I plan to replace the copy operation with another and will also consider this. 👍
Related to #103 #163

peaceiris added a commit that referenced this issue Jul 21, 2020
peaceiris pushed a commit that referenced this issue Jul 21, 2020
@peaceiris

This comment has been minimized.

@peaceiris

This comment has been minimized.

@peaceiris
Copy link
Owner

The v3.7.0-4 has been released as a beta release.

- name: Deploy
  uses: peaceiris/[email protected]
  with:
    github_token: ${{ secrets.GITHUB_TOKEN }}
    destination_dir: subdir

@peaceiris peaceiris mentioned this issue Oct 11, 2020
1 task
@peaceiris
Copy link
Owner

peaceiris commented Oct 11, 2020

If you have something wrong, please feel free to open another issue. 👍

@peaceiris peaceiris mentioned this issue Oct 15, 2020
1 task
peaceiris added a commit that referenced this issue Oct 15, 2020
Close #520

Related to:

- pr: #512 
- #507 #509 
- #390
- #324
- #103
peaceiris pushed a commit that referenced this issue Oct 15, 2020
Close #520

Related to:

- pr: #512
- #507 #509
- #390
- #324
- #103
@github-actions
Copy link
Contributor

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.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jun 25, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants