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

actions/checkout@v2 deletes all the files within the repo directory before fetching from remote #430

Closed
vicke4 opened this issue Jan 20, 2021 · 3 comments

Comments

@vicke4
Copy link

vicke4 commented Jan 20, 2021

Hi,

I have a GitHub self-hosted runner set up to deploy a Next.js app that checkouts the repository, builds and restarts pm2.

The thing is whenever the actions/checkout@v2 step kicks in, it deletes all the files within the repository including the folder .next that contains all the build files. This leads to the downtime of the application whenever the workflow runs.

Is there any way I can opt-out of the deletion of the build files? If there's no way as of now, can I submit a pull request with a YAML config for that?

Link to my StackOverflow question regarding this issue.

@ericsciple
Copy link
Contributor

Try setting the input clean to false https://github.com/actions/checkout#usage

@vicke4
Copy link
Author

vicke4 commented Jan 21, 2021

Thanks, @ericsciple. It works!

However, if you already have a workflow that uses actions/checkout@v2 which had run at least once without clean: false, updating your config to have clean: false doesn't work the first time. This is because the .git folder will not be there - https://github.com/actions/checkout/blob/main/src/git-directory-helper.ts#L23. It starts to work in the subsequent runs. This was the reason for me to raise this issue.

Maybe we can update this in the README to avoid the confusion for others.

@vicke4 vicke4 closed this as completed Jan 21, 2021
@iceener
Copy link

iceener commented Mar 31, 2021

Thanks, @ericsciple. It works!

However, if you already have a workflow that uses actions/checkout@v2 which had run at least once without clean: false, updating your config to have clean: false doesn't work the first time. This is because the .git folder will not be there - https://github.com/actions/checkout/blob/main/src/git-directory-helper.ts#L23. It starts to work in the subsequent runs. This was the reason for me to raise this issue.

Maybe we can update this in the README to avoid the confusion for others.

In my case the problem is still there. Each run ends up with cleared directory.
Is there anything else I should do to prevent this?

edit:
Solved but it required a few steps:

  • make sure that your git version on self-hosted machine is above 2.18
    sudo add-apt-repository -y ppa:git-core/ppa
    sudo apt-get update
    sudo apt-get install git -y
  • make sure that your default branch is set to main instead of master
    git config --global init.defaultBranch main

TilmoDev added a commit to TilmoDev/tilmodev.github.io that referenced this issue Jul 21, 2024
- The below link suggests that the '.next' is being cleaned out which contains build files,
  it's suggested that clean: 'false' should prevent that.
  > actions/checkout#430 (comment)
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

3 participants