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

[bug] Setting clean to false still removes contents #1201

Open
SReject opened this issue Mar 6, 2023 · 8 comments
Open

[bug] Setting clean to false still removes contents #1201

SReject opened this issue Mar 6, 2023 · 8 comments

Comments

@SReject
Copy link

SReject commented Mar 6, 2023

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
@SReject SReject changed the title Setting clean to false still removes contents [bug] Setting clean to false still removes contents Mar 6, 2023
@zh3305
Copy link

zh3305 commented Mar 11, 2023

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"

@ermshiperete
Copy link

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.

@ermshiperete
Copy link

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/

ermshiperete added a commit to keymanapp/keyman that referenced this issue Jun 3, 2024
In #11571 we tried to fix the failing API verification by moving
setting up the environment and restoring artifacts to the same job
as the api verification itself. However, this doesn't help and the
`artifacts` subdirectory still vanishes, caused by
actions/checkout#1201.

This change reverts the change introduced in #11571 and changes the
git checkout to end in a separate subdirectory.

Reverts: #11571
ermshiperete added a commit to keymanapp/keyman that referenced this issue Jun 3, 2024
… dir

In #11571 we tried to fix the failing API verification by moving
setting up the environment and restoring artifacts to the same job
as the api verification itself. However, this doesn't help and the
`artifacts` subdirectory still vanishes, caused by
actions/checkout#1201.

This change reverts the change introduced in #11571 and changes the
git checkout to end in a separate subdirectory.

Reverts: #11571
@muzimuzhi
Copy link

The explanation given in PR #561 still holds:

else if (
!fsHelper.directoryExistsSync(path.join(repositoryPath, '.git')) ||
repositoryUrl !== (await git.tryGetFetchUrl())
) {
remove = true
} else {

At present, if the repository directory doesn't contain a .git directory 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.

@TimWoerner
Copy link

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

@sanduluca
Copy link

Any update or workaround for this ?

@aryhan-upupapp
Copy link

any update on this?

@alex-3881
Copy link

seems to still be a problem

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

8 participants