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

Support checkout of subdirectory into working directory #1430

Open
srgoni opened this issue Aug 15, 2023 · 6 comments
Open

Support checkout of subdirectory into working directory #1430

srgoni opened this issue Aug 15, 2023 · 6 comments

Comments

@srgoni
Copy link

srgoni commented Aug 15, 2023

GitHub Actions are somewhat limited in what paths can be used in which tasks.

With run: steps, it's possible to set a custom working directory with the working-directory option, but this is not supported for uses: steps.

The only ways to make a custom container run in a subtree of a checkout are

  • with custom container options (which the container must support in some way)
  • by manually moving all relevant files from the checkout to the root of the workspace

Neither option is very convenient (and sometimes even impossible) or robust.

One possible solution to this problem could be to support working-directory in uses: steps, or the checkout action could support checking out only a subtree of a repository.

This can be implemented with git write-tree and git read-tree -um, as described here: https://stackoverflow.com/questions/30239659/git-clone-only-a-subdirectory-at-the-root-of-the-current-directory/30244250#30244250
Or a sparse checkout could be done and the contents of the subtree moved to the root of the working directory.

Note that this is the opposite of the path: option of the checkout action.

@danial-k
Copy link

danial-k commented Oct 10, 2023

+1, would make using actions with monorepos a lot easier. Currently having to use sparse-checkout and sparse-checkout-cone-mode and then moving directories, e.g. (Inspired by #483):

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

@MarkBNinetyOne
Copy link

+1, this would be great.

@Shion1305
Copy link

+1

@thatguyinabeanie
Copy link

+1

2 similar comments
@DiogoLobo122
Copy link

+1

@Lemminkyinen
Copy link

+1

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

7 participants