From 81a82f03ab807a1cf9b0a554d465b50c3105a16f Mon Sep 17 00:00:00 2001 From: Joshua Gilman Date: Fri, 30 Aug 2024 17:31:21 -0400 Subject: [PATCH] feat: adds discover action --- .github/workflows/test.yml | 26 +++++++++++++++++++++++++ forge/actions/discovery/action.yml | 31 ++++++++++++++++++++++++++++++ 2 files changed, 57 insertions(+) create mode 100644 .github/workflows/test.yml create mode 100644 forge/actions/discovery/action.yml diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 00000000..c4e48782 --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,26 @@ +name: Test +on: + push: + +permissions: + contents: read + id-token: write + +jobs: + test: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Setup + uses: ./forge/actions/setup + with: + forge_version: local + - name: Discovery + id: discovery + uses: ./forge/actions/discovery + with: + filters: | + ^check.* + ^test.* + - name: Show output + run: echo "${{ steps.discovery.outputs.json }}" \ No newline at end of file diff --git a/forge/actions/discovery/action.yml b/forge/actions/discovery/action.yml new file mode 100644 index 00000000..f96a2046 --- /dev/null +++ b/forge/actions/discovery/action.yml @@ -0,0 +1,31 @@ +name: Discovery +description: Discovers Earthfiles +inputs: + filters: + description: A newline separated list of filters to apply + default: "" + path: + description: The path to search from + default: "." +outputs: + json: + description: The result of the discovery + value: ${{ steps.discover.outputs.json }} +runs: + using: composite + steps: + - name: Discover + id: discover + shell: bash + run: | + FILTERS="${{ inputs.filters }}" + FILTERS="$(echo "${FILTERS}" | tr '\n' ' ' | sed 's/ $//')" + + FLAGS="" + for filter in $FILTERS; do + FLAGS+="-f $filter " + done + + OUTPUT=$(forge -vvv scan $FLAGS "${{ inputs.path }}" 2> >(tee /dev/stderr)) + OUTPUT=$(echo $OUTPUT | jq -rc) + echo "json=$OUTPUT" >> $GITHUB_OUTPUT \ No newline at end of file