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

Post Check out code is not able to reset the git state #594

Open
nedrebo opened this issue Oct 1, 2021 · 2 comments
Open

Post Check out code is not able to reset the git state #594

nedrebo opened this issue Oct 1, 2021 · 2 comments

Comments

@nedrebo
Copy link

nedrebo commented Oct 1, 2021

We are using self-hosted runners and the checkout action. Recently we had a situation where code in one branch managed to break the builds of other branches.

What was done was to add the second step below.

steps:
    - name: Check out code
      uses: actions/checkout@v2
      with:
          lfs: true
    - name: Remove non-dependencies
      run: |
          git sparse-checkout init --cone
          git sparse-checkout set project1/src

This caused a git state that Post Check out code did not manage to recover from.

When a new job later started on the same runner and that job needed files outside of project1/src it failed.

I think this case should be handled by the checkout action so that after the Post Check out code step the state in git is the same as after the Check out code step above.

@david-frautnick
Copy link

The same issue happens when using the sparse-checkout option. For example, I have a job with the following step:

      - name: Fetch Source
        uses: actions/checkout@v3
        with:
          sparse-checkout: |
            dirA
            dirB

This works fine, however, I have another job that does not use sparse-checkout like this:

      - name: Fetch Source
        uses: actions/checkout@v3

If this second job re-uses the same work folder on my runner server, it will not checkout the full repository because the previous job had it set to sparse-checkout. It would be great if the Post Fetch Source step would reset the sparse-checkout setting for subsequent jobs that reuse the same work folder.

@Wei18
Copy link

Wei18 commented Sep 12, 2023

Hi,
I use this to workaround, but it's good to see author put git sparse-checkout disable in the post job.

steps:
    - uses: actions/checkout@v3
      with:
        sparse-checkout: |
          .github
    - run: git sparse-checkout disable # [Workaround] Reset previous sparse-checkout

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

3 participants