Skip to content

martinhaintz/ga-file-list

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

Repository files navigation

Lists all Files (in optional Subdirectory)

javscript-action status

This small and simple plugin lists all files of a directory and returns the output as json. This json can be later used for a dynamic build matrix.

Inputs

directory

Optional The directory to look for the files. Default "project root".

file_extension

Optional File extension filter. (e.g., "txt","yml")

only_files_starts_with

Optional List of values for which starts with are only used. (e.g., "dev_,test,config-")

only_files_starts_with_delimiter

Optional Delimiter for the only list. (Default: ",")

ignore_files_starts_with

Optional List of values for which files should be ignored. (e.g., "ignore_,test,config-")

ignore_files_starts_with_delimiter

Optional Delimiter for the ignore list. (Default: ",")

Outputs

files

The list of files including file extension as json

file_names

The list of files names without file extension as json

Usage

uses: the-coding-turtle/[email protected]

Or with optional parameters:

uses: the-coding-turtle/[email protected]
with:
  directory: "configs"
  file_extension: "yml"
  ignore_files_starts_with: "ignore_;test;config-"
  ignore_files_starts_with_delimiter: ";"

Matrix Build / Multi-Tenancy for Google AppEngine (My use case)

name: Multi Tenant GAE Deploy

on:
  push:
  workflow_dispatch:

jobs:
  lookup:
    runs-on: ubuntu-latest
    outputs:
      matrix: ${{ steps.filelist.outputs.file_names }}
    steps:
    - uses: actions/checkout@v2
    - name: Get all yaml files
      id: filelist
      uses: the-coding-turtle/[email protected]
      with:
        directory: "gae_yaml"
        file_extension: "yaml"

  multi_tenant:
    needs: lookup
    runs-on: ubuntu-latest
    strategy:
      matrix:
        tenant: ${{fromJson(needs.lookup.outputs.matrix)}}
    steps:
    - uses: actions/checkout@v2
    - name: Show all tenants
      run: |
        echo "this is tenant: ${{ matrix.TENANT }}"