DEV Community

Jean-Francis Bastien
Jean-Francis Bastien

Posted on

Checkout only certain files

My Workflow

Bhacaz/checkout-files is useful to only pull specific files from a repository instead of the hold project with the well known actions/checkout. Some project can be very heavy to pull when what you need it’s just 2 or 3 files.

It can be useful if you only need package config files like package.json or Gemfile to setup a Github Action environment, since popular action like ruby/setup-ruby look for the .ruby-version to automatically determine which version to setup and the Gemfile.lock to install the right version of bundler. I personally use it along with an other script to run bundle outdated on a Ruby project. For more details have a look on my other post.

Submission Category:

Wacky Wildcards. Because it's a very general action that can be use for multiple case.

Yaml File or Link to Code

GitHub logo Bhacaz / checkout-files

Github Action checkout only certain files

checkout-files

⚠️ Please consider using actions/checkout with the option sparse-checkout.

GitHub Action to checkout only certain files and/or folders Useful if only need certain files, like config or assets for your workflow, instead of pulling the whole repo.

Usage

Minimal setup.

- name: Checkout files
  uses: Bhacaz/checkout-files@v2
  with:
   files: package.json
Enter fullscreen mode Exit fullscreen mode

Inputs

Name Description Required Default
files A list of files with the path separated by a space, relative to root of your repository. Can also be a folder and the action will recursively pull all the files. true N/A
token A GitHub token. false ${{ github.token }}
branch Checkout files from a specific branch. If not specified, it use the default repository branch.
To use the current working branch ${{ github.head_ref || github.ref_name }}
false Default branch of the repository.

Limitations

  • This action doesn't keep the mode bits (or permission) of files. See #18 for…

Additional Resources / Info

You can find an example of usage in this Ruby on Rails project of mine. Bhacaz/democraylist-be.github/workflows/outdated_gems.yml

Top comments (0)