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

Path variable doesn't set up git properly #1770

Open
henrygriffiths opened this issue Jun 11, 2024 · 0 comments
Open

Path variable doesn't set up git properly #1770

henrygriffiths opened this issue Jun 11, 2024 · 0 comments

Comments

@henrygriffiths
Copy link

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.

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

1 participant