From 6e758b284b9527f4c14bf3fc6cd0819e4f48d228 Mon Sep 17 00:00:00 2001 From: Kyle Harding Date: Thu, 4 Apr 2024 22:38:04 -0400 Subject: [PATCH] Pre-process files list for conditional steps Change-type: minor Signed-off-by: Kyle Harding --- .github/workflows/flowzone.yml | 17 +++++++++++++++++ flowzone.yml | 18 ++++++++++++++++++ 2 files changed, 35 insertions(+) diff --git a/.github/workflows/flowzone.yml b/.github/workflows/flowzone.yml index 666f85f45..95b39766f 100644 --- a/.github/workflows/flowzone.yml +++ b/.github/workflows/flowzone.yml @@ -624,12 +624,29 @@ jobs: uses: docker://rhysd/actionlint:1.6.27 with: args: -color -shellcheck= + process_files: + name: Process files + runs-on: ${{ fromJSON(inputs.runs_on) }} + timeout-minutes: ${{ fromJSON(inputs.jobs_timeout_minutes) }} + defaults: + run: + working-directory: ${{ inputs.working_directory }} + shell: bash --noprofile --norc -eo pipefail -x {0} + outputs: + json: ${{ steps.process_files.outputs.json }} + steps: + - name: Generate file list json + id: process_files + run: | + echo "json=$(git ls-files | jq -R -s -c 'split("\n")[:-1]')" >> $GITHUB_OUTPUT is_npm: name: Is npm runs-on: ${{ fromJSON(inputs.runs_on) }} timeout-minutes: ${{ fromJSON(inputs.jobs_timeout_minutes) }} needs: - versioned_source + - process_files + if: contains(fromJSON(needs.process_files.outputs.json), 'package.json') defaults: run: working-directory: ${{ inputs.working_directory }} diff --git a/flowzone.yml b/flowzone.yml index b9750c09c..795d93e02 100644 --- a/flowzone.yml +++ b/flowzone.yml @@ -1209,6 +1209,22 @@ jobs: # disable shellcheck for now args: -color -shellcheck= + process_files: + name: Process files + runs-on: ${{ fromJSON(inputs.runs_on) }} + timeout-minutes: ${{ fromJSON(inputs.jobs_timeout_minutes) }} + + <<: *customWorkingDirectory + + outputs: + json: ${{ steps.process_files.outputs.json }} + + steps: + - name: Generate file list json + id: process_files + run: | + echo "json=$(git ls-files | jq -R -s -c 'split("\n")[:-1]')" >> $GITHUB_OUTPUT + # check if the repository has a package.json file and which engine versions are supported is_npm: name: Is npm @@ -1216,6 +1232,8 @@ jobs: timeout-minutes: ${{ fromJSON(inputs.jobs_timeout_minutes) }} needs: - versioned_source + - process_files + if: contains(fromJSON(needs.process_files.outputs.json), 'package.json') <<: *customWorkingDirectory