From 54033c4a6402b4102d4fc1b58559fff352336b79 Mon Sep 17 00:00:00 2001 From: SciLor Date: Wed, 14 Aug 2024 18:54:29 +0000 Subject: [PATCH] fix space error --- .github/workflows/publish_docker_matrix.yml | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/.github/workflows/publish_docker_matrix.yml b/.github/workflows/publish_docker_matrix.yml index 11ba0533..c4ad2679 100644 --- a/.github/workflows/publish_docker_matrix.yml +++ b/.github/workflows/publish_docker_matrix.yml @@ -26,26 +26,24 @@ jobs: run: | # Find all YAML files in the .github/workflows directory that start with "publish_docker_matrix_" workflows=$(find .github/workflows -name 'publish_docker_matrix_*.yml' -exec basename {} \;) - echo "workflows=$workflows" >> $GITHUB_ENV - - - name: Set Matrix - id: set_matrix - run: | - # Convert the workflows list into a JSON array format for matrix inclusion - matrix_json=$(echo "[\"$(echo $workflows | sed 's/ /\",\"/g')\"]") + echo "Found workflows: $workflows" + # Convert to JSON array + matrix_json=$(echo "[\"$(echo $workflows | tr ' ' '\n' | sed 's/$/\",/' | tr -d '\n' | sed 's/,$//')\"]") echo "matrix_json=$matrix_json" >> $GITHUB_ENV - name: Trigger Workflows uses: actions/github-script@v6 + env: + MATRIX_JSON: ${{ env.matrix_json }} with: script: | - const matrix = JSON.parse(process.env.matrix_json); + const matrix = JSON.parse(process.env.MATRIX_JSON); console.log("Triggering workflows: ", matrix); for (const workflow of matrix) { const owner = context.repo.owner; const repo = context.repo.repo; const event_type = 'trigger-workflow'; // Matches the repository_dispatch trigger - const client_payload = { "branch": process.env.branch }; + const client_payload = { "branch": process.env.GITHUB_REF_NAME }; await github.repos.createDispatchEvent({ owner, @@ -54,4 +52,4 @@ jobs: client_payload, workflow }); - } + }; \ No newline at end of file