Skip to content

Checkout Specific Folder/Directory/Path within GitHub Repository #483

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

Open
NickLiffen opened this issue Apr 23, 2021 · 8 comments
Open

Checkout Specific Folder/Directory/Path within GitHub Repository #483

NickLiffen opened this issue Apr 23, 2021 · 8 comments

Comments

@NickLiffen
Copy link

👋

Let's say I have repositoryA that has a high-level folder structure of:

- .github
- actions
- docs
- tests
readme.md
...

I also have a repository called repositoryB. From repositoryB, I am trying to checkout repositoryA. I have that working by something like the below:

      - name: Checkout Central Actions Repo
        uses: actions/checkout@v2
        with:
          repository: ${{org}}/repositoryA
          ref: main
          token: ${{ secrets.token }}
          persist-credentials: false
          path: ./github-app-jwt-action

This works and checks out the whole repository. I am looking for a way to only checkout the actions
directory from repositoryA, vs the whole repository. I was thinking something like this would work:

      - name: Checkout Central Actions Repo
        uses: actions/checkout@v2
        with:
          repository: ${{org}}/repositoryA
          ref: main
          token: ${{ secrets.token }}
          persist-credentials: false
          path: ./github-app-jwt-action
          dir: ./actions

This obviously isn't possible, but I wondered if there was another way around this?

@rexwangcc
Copy link

rexwangcc commented Jul 14, 2021

Having a similar use case, I noticed that there's a way to achieve that using git commands, as explained here, but it would be great if there's an Actions solution too :-)

@gnrlbzik
Copy link

gnrlbzik commented Nov 1, 2021

There is this github action i found: https://github.com/marketplace/actions/checkout-files

@andyslack
Copy link

We are moving towards one repo per client which holds both their backend and frontend to save having multiple repos per client. This feature would be really helpful for me.

@LeviPesin
Copy link

Isn't this supported since v3.5.3 by using sparse-checkout?

@andyslack
Copy link

Isn't this supported since v3.5.3 by using sparse-checkout?

Works like a dream 👍

@danial-k
Copy link

Example with sparse checkout (would be nice if this was handled with a shortcut per #1430 ):

jobs:
  eas-preview:
    name: EAS preview
    runs-on: ubuntu-latest
    steps:
      # Checkout project code
      # Use sparse checkout to only select files in mobile app directory
      # Turning off cone mode ensures that files in the project root are not included during checkout
      - uses: actions/checkout@v3
        with:
          sparse-checkout: 'frontend/mobile'
          sparse-checkout-cone-mode: false

      # This step is needed because expo-github-action does not support paths.
      # Therefore all mobile app assets should be moved to the project root.
      - name: Move mobile app files to root
        run: |
          ls -lah
          shopt -s dotglob
          mv frontend/mobile/* .
          rm -rf frontend
          ls -lah

@ashishjullia
Copy link

Were you able to find a cleaner way? @danial-k

@rsmartins78
Copy link

This is working for me

        uses: actions/checkout@v4
        with:
          repository: user/repo_name
          path: 'destination_folder'
          sparse-checkout: 'folder_to_clone_from_$repository'
          sparse-checkout-cone-mode: false
          token: ${{ secrets.PAT_REPO_TOKEN }} ```

Kuoste added a commit to Kuoste/LasUtility that referenced this issue Jun 12, 2024
trying sparse checkout as in actions/checkout#483
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