Skip to content

Commit 928e2a2

Browse files
authored
Fix non-matrix mode (#21)
## what * Fix the action fail if `matrix-step-name` is empty, which is the correct input for `non-matrix` mode ## why * Fix - https://github.com/cloudposse/example-app-on-ecs/actions/runs/5081215074 - https://github.com/cloudposse/example-app-on-eks-with-argocd/actions/runs/5080777018 ## Ref * ttps://github.com/cloudposse/github-actions-workflows/blob/main/.github/workflows/ci-dockerized-app-promote.yml
1 parent 225642c commit 928e2a2

File tree

5 files changed

+27
-1
lines changed

5 files changed

+27
-1
lines changed

.github/workflows/test-non-matrix.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ jobs:
3030
3131
outputs:
3232
result: "${{ steps.current.outputs.result }}"
33+
outcome: "${{ steps.current.outcome }}"
3334

3435
assert:
3536
runs-on: ubuntu-latest
@@ -40,6 +41,12 @@ jobs:
4041
expected: '{"result":"one"}'
4142
actual: "${{ needs.test.outputs.result }}"
4243

44+
- uses: nick-fields/assert-action@v1
45+
with:
46+
expected: 'success'
47+
actual: "${{ needs.test.outputs.outcome }}"
48+
49+
4350
- uses: nick-fields/assert-action@v1
4451
with:
4552
expected: 'one'

.github/workflows/test-positive.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ jobs:
5252
5353
outputs:
5454
result: "${{ steps.current.outputs.result }}"
55+
outcome: "${{ steps.current.outcome }}"
5556

5657
assert:
5758
runs-on: ubuntu-latest
@@ -62,6 +63,10 @@ jobs:
6263
expected: '2'
6364
actual: "${{ needs.test.outputs.result }}"
6465

66+
- uses: nick-fields/assert-action@v1
67+
with:
68+
expected: 'success'
69+
actual: "${{ needs.test.outputs.outcome }}"
6570

6671
teardown:
6772
runs-on: ubuntu-latest

.github/workflows/test-reusable-workflow.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ jobs:
2929
echo "result=$(ls | wc -l)" >> $GITHUB_OUTPUT
3030
3131
outputs:
32+
outcome: "${{ steps.current.outcome }}"
3233
result: "${{ steps.current.outputs.result }}"
3334

3435
assert:
@@ -40,6 +41,11 @@ jobs:
4041
expected: '2'
4142
actual: "${{ needs.test.outputs.result }}"
4243

44+
- uses: nick-fields/assert-action@v1
45+
with:
46+
expected: 'success'
47+
actual: "${{ needs.test.outputs.outcome }}"
48+
4349
teardown:
4450
runs-on: ubuntu-latest
4551
needs: [assert]

.github/workflows/test-special-chars.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ jobs:
9494
echo "result=$(ls | wc -l)" >> $GITHUB_OUTPUT
9595
9696
outputs:
97+
outcome: "${{ steps.current.outcome }}"
9798
result: "${{ steps.current.outputs.result }}"
9899

99100
assert:
@@ -105,6 +106,11 @@ jobs:
105106
expected: '2'
106107
actual: "${{ needs.test.outputs.result }}"
107108

109+
- uses: nick-fields/assert-action@v1
110+
with:
111+
expected: 'success'
112+
actual: "${{ needs.test.outputs.outcome }}"
113+
108114

109115
teardown:
110116
runs-on: ubuntu-latest

index.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ try {
3232
return
3333
}
3434

35+
const matrix_mode = !isEmptyInput(step_name) && !isEmptyInput(matrix_key)
36+
3537
if (!isEmptyInput(outputs)) {
3638
try {
3739
yaml.parse(outputs)
@@ -61,7 +63,7 @@ ${error}`;
6163

6264
core.setOutput('result', JSON.stringify(outputs_struct))
6365

64-
if (!isEmptyInput(outputs)) {
66+
if (!isEmptyInput(outputs) && matrix_mode) {
6567
const artifact_content = isEmptyInput(matrix_key) ? outputs_struct : { [matrix_key]: outputs_struct }
6668

6769
fs.writeFileSync("./" + step_name, JSON.stringify(artifact_content));

0 commit comments

Comments
 (0)