Support checkout of subdirectory into working directory
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.
+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 https://github.com/actions/checkout/issues/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
+1, this would be great.
+1
+1
+1
+1
+1