diff --git a/.github/workflows/__test-action-matrix-outputs.yml b/.github/workflows/__test-action-matrix-outputs.yml index 453fbd97..a913077a 100644 --- a/.github/workflows/__test-action-matrix-outputs.yml +++ b/.github/workflows/__test-action-matrix-outputs.yml @@ -18,13 +18,15 @@ jobs: - id: set-matrix-output-1 uses: ./actions/set-matrix-output with: - value: '"test content 1"' + value: | + { "test": "test content 1" } artifact-name: "test-matrix-outputs-${{ matrix.os }}" - id: set-matrix-output-2 uses: ./actions/set-matrix-output with: - value: '"test content 2"' + value: | + { "test": "test content 2" } artifact-name: "test-matrix-outputs-${{ matrix.os }}" - name: Check set matrix outputs @@ -50,7 +52,9 @@ jobs: - name: Check matrix outputs shell: bash run: | - if [ "${{ steps.get-matrix-outputs.outputs.result }}" != '["test content 1","test content 2"]' ]; then + OUTPUT_RESULT='${{ steps.get-matrix-outputs.outputs.result }}' + + if [ "$OUTPUT_RESULT" != '[{ "test": "test content 1" },{ "test": "test content 2" }]' ]; then echo "Get matrix outputs result is not valid" exit 1 fi diff --git a/actions/get-matrix-outputs/action.yml b/actions/get-matrix-outputs/action.yml index 9e014688..63408ae5 100644 --- a/actions/get-matrix-outputs/action.yml +++ b/actions/get-matrix-outputs/action.yml @@ -19,7 +19,7 @@ inputs: outputs: result: description: "The matrix combined JSON outputs." - value: ${{ steps.read-artifacts.outputs.result }} + value: ${{ steps.read-artifacts.outputs.artifacts }} runs: using: "composite" @@ -51,15 +51,15 @@ runs: core.debug(`Found ${artifactFiles.length} files in ${artifactPath}`); - const result = artifactFiles.map(file => readFileSync(file, 'utf8')).join(","); + const result = artifactFiles.map(file => readFileSync(file, 'utf8').trim()).join(","); + + core.setOutput('artifacts',`[${result}]`); const shouldRemoveArtifact = `${{ inputs.remove-artifact }}` === 'true'; if(shouldRemoveArtifact) { await io.rmRF(artifactPath); } - return `[${result}]`; - - if: ${{ inputs.remove-artifact == 'true' }} uses: geekyeggo/delete-artifact@v2 with: diff --git a/actions/set-matrix-output/action.yml b/actions/set-matrix-output/action.yml index 20fc598c..8e3c682a 100644 --- a/actions/set-matrix-output/action.yml +++ b/actions/set-matrix-output/action.yml @@ -42,7 +42,10 @@ runs: let matrixOutputFile = ''; for (let i = 1; i <= maxAttempts; i++) { const uniquid = randomUUID(); - matrixOutputFile = join(artifactPath, `${artifactName}-${uniquid}.json`); + const timestamp = Date.now(); + const matrixOutputFileName = `${timestamp}-${artifactName}-${uniquid}.json`; + + matrixOutputFile = join(artifactPath, matrixOutputFileName); if (!existsSync(matrixOutputFile)) { break; }