actions/checkout@v2 deletes all the files within the repo directory before fetching from remote
Closed this issue ยท 3 comments
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?
Try setting the input clean
to false
https://github.com/actions/checkout#usage
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.
Thanks, @ericsciple. It works!
However, if you already have a workflow that uses
actions/checkout@v2
which had run at least once withoutclean: false
, updating your config to haveclean: 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