Skip to content

Get a list of folders in a directory and return them as a json list

License

Notifications You must be signed in to change notification settings

SuperEvilMegacorp/list-folder-action

Use this GitHub action with your project
Add this Action to an existing workflow or create a new one
View on Marketplace
 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 

Repository files navigation

List folders of path Action

This action lists the folders in the given directory and returns them as a json formatted list.

This is useful for using in subsequent jobs as the matrix command so you can run a job per sub folder.

This is currently a simple composite action. It ensures that all tools needed are installed by running apt-get install or brew install commands. Therefore it is advised to run this inside a debian/ubuntu/macos based runner or container.

Inputs

Name Description Required Default
path The path of a folder to list the sub folders of true
dir_name Whether to include the given path in the folders name or not false false
escape Whether the output JSON should be escaped or not false false
suffix Suffix to add at each folders false

Outputs

Name Description
folders The json formatted string list of sub folders

Example

This action can be used to list the folders and input them into a matrix for a subsequent job.

jobs:
  find-jobs:
    name: Find Jobs
    container: debian:buster-slim
    outputs:
      folders: ${{ steps.jobs.outputs.folders }}
    steps:
      - uses: actions/checkout@v1

      - id: jobs
        uses: SuperEvilMegacorp/list-folders-action@v9
        with:
          path: ./path/to/folder

  matrix:
    name: Matrix Jobs
    needs: [find-jobs]
    container: ubuntu
    defaults:
      run:
        working-directory: ${{ matrix.folder }}
    strategy:
      matrix:
        folder: ${{ fromJson(needs.find-jobs.outputs.folders )}}
    steps:
      - name: do something
        run: echo ${{ matrix.folder }}

About

Get a list of folders in a directory and return them as a json list

Resources

License

Stars

Watchers

Forks

Packages

No packages published