[bug] Setting clean to false still removes contents
Context
I'm currently attempting a duel repo setup where one builds nightlies for the other.
I checkout the nightly-builder repo into ./nightly
I checkout the main repo into './' with the clean option set to false
Expected behavior:
./nightly directory to exist after checking out main repo
Current Behavior:
./nightly directory is deleted
Relevant workflow.yml parts
jobs:
getInfo:
name: Get build Info
runs-on: ubuntu-latest
outputs:
version: ${{ steps.getinfo.outputs.version }}
patchnotes: ${{ steps.getinfo.outputs.patchnotes }}
steps:
- name: Checkout crowbartools/firebot-nightly
uses: actions/checkout@v3
with:
path: './nightly/'
- name: Checkout crowbartools/firebot
uses: actions/checkout@v3
with:
clean: false
fetch-depth: 0
repository: 'crowbartools/firebot'
ref: 'v5'
path: '.'
- name: Get Firebot info
id: getinfo
# This errors because /nightly directory has been deleted
run: node ./nightly/scripts/get-info.js $GITHUB_OUTPUT
Please check that the check-out directory contains the .git directory. Please check whether the output log has. "To create a local Git repository instead, add Git 2.18 or higher to the PATH"
I have a similar situation where I restore artifacts from a cache to the artifacts subdirectory and afterwards run the checkout action with clean: false. This causes the artifacts subdirectory to disappear.
A simple repro would be:
name: "Checkout bug #1201"
on:
workflow_dispatch:
jobs:
test:
runs-on: ubuntu-latest
steps:
- name: Restore artifacts
run: |
mkdir artifacts/
echo "Hello world" > artifacts/hello
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
clean: false
- name: Verify
run: |
ls -al
ls -al artifacts/
The explanation given in PR #561 still holds:
https://github.com/actions/checkout/blob/6d193bf28034eafb982f37bd894289fe649468fc/src/git-directory-helper.ts#L27-L32
At present, if the repository directory doesn't contain a
.gitdirectory then the action always erases the entire repository directory, regardless of the "clean" setting.
PR #561, opened in Aug 2021 and still open in Sep 2024, proposed a change to respect clean input setting when the repository directory doesn't contain a .git directory.
This also indicates the current (v4.1.7) doc of clean input is over-simplified hence misleading.
any news on that or a workaround?
I also have a multi step build pipeline, that later tries to upload the packages from the Build.ArtifactStagingDirectory but it keeps getting deleted, even if the steps.clean property is set to false
Resolved: this is by design: https://learn.microsoft.com/en-us/azure/devops/pipelines/repos/azure-repos-git?view=azure-devops&tabs=yaml#clean-build
... Note that the $(Build.ArtifactStagingDirectory) and ... are always deleted and recreated prior to every build regardless of any of these settings.
Instead $(Build.BinariesDirectory) should be used to store and persist build binaries
Any update or workaround for this ?
any update on this?
seems to still be a problem
This is still a problem
Any workaround for this? 👎 I'm working with sub-modules and it's a problem. To fix it I manually download both repositories and do some magic moving the folders inside the vm.