Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions .github/workflows/__test-action-matrix-outputs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
8 changes: 4 additions & 4 deletions actions/get-matrix-outputs/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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:
Expand Down
5 changes: 4 additions & 1 deletion actions/set-matrix-output/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down