question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Can't overwrite files on the branch with the action

See original GitHub issue

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

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:8 (7 by maintainers)

github_iconTop GitHub Comments

2reactions
illrightcommented, Jul 10, 2020

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.

0reactions
github-actions[bot]commented, Jun 25, 2021

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>
Read more comments on GitHub >

github_iconTop Results From Across the Web

How do I force git pull to overwrite local files? - Tower Git Client
Step 1: Cleaning Up the Working Copy · a) Saving Local Changes on a Stash · b) Discarding Local Changes.
Read more >
Unable to overwrite Git master branch with dev branch
I know my dev branch is OK and I don't want anything to happen to it so I'm trying to replace my master...
Read more >
Local changes to the following files will be overwritten
The Git “Your local changes to the following files would be overwritten by checkout” error occurs when you make changes on two branches...
Read more >
Switching from branch-a to branch-b changes file permissions ...
When I checkout the master branch, why do those changes to permissions occur? I thought Git tracked only the execute permission for the...
Read more >
Introduction to Git rebase and force-push - GitLab Docs
You can replace main with any other branch you want to rebase against, ... your feature branch directly from the merge request through...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found