Skip to content

Path variable doesn't set up git properly #1770

@henrygriffiths

Description

@henrygriffiths

When using the path variable to clone a repository into another folder, the repo is not cloned to the correct commit, and git is not set up properly

jobs:
  backup:
    runs-on: [self-hosted]
    steps:
    - name: Checkout
      uses: actions/checkout@v4
      with:
        path: folder
        ref: ${{ github.sha }}

    - name: CD
      run: |
        cd folder

    - name: Log Commit Hash
      run: |
        echo ${{ github.sha }} && git log -1 --format='%H'

Expected Result:

abcde
abcde

Actual Result:

abcde
defgh

Despite the final debug log from actions/checkout of git log -1 --format='%H' producing the correct value, when run in the cloned repository, it shows a different (older) commit hash.

The script does not set up authentication, so git pull origin <branch> is not possible.
The cloned repository is at a different point in time. git reset --hard HEAD reverts to that commit and git reset --hard abcde results in the hash not being known.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions