actions / checkout

Action for checking out a repo
https://github.com/features/actions
MIT License
5.46k stars 1.61k forks source link

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

Open SReject opened 1 year ago

SReject commented 1 year ago

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
zh3305 commented 1 year ago

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 commented 4 weeks ago

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 commented 4 weeks ago

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/