Skip to content

Commit 90c21f6

Browse files
authored
Test multiple outputs (#7)
1 parent 4653b00 commit 90c21f6

File tree

2 files changed

+33
-13
lines changed

2 files changed

+33
-13
lines changed

.github/workflows/test-positive.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,18 @@ jobs:
2727
matrix-key: ${{ matrix.target }}
2828
outputs: |-
2929
result: ${{ matrix.target }}
30+
test: existing_value
3031
3132
- uses: nick-fields/assert-action@v1
3233
with:
3334
expected: ${{ matrix.target }}
3435
actual: ${{ fromJson(steps.writer.outputs.result).result }}
3536

37+
- uses: nick-fields/assert-action@v1
38+
with:
39+
expected: existing_value
40+
actual: ${{ fromJson(steps.writer.outputs.result).test }}
41+
3642
test:
3743
runs-on: ubuntu-latest
3844
continue-on-error: true

action.yml

Lines changed: 27 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -35,26 +35,40 @@ runs:
3535
actual: "${{ inputs.matrix-key }}"
3636
comparison: notEqual
3737

38-
- uses: cloudposse/[email protected]
39-
id: proxy
38+
- name: 'Install jq 1.6'
39+
uses: dcarbone/[email protected]
4040
with:
41-
query: .
42-
config: |-
43-
result:
44-
${{ inputs.outputs }}
41+
version: 1.6
42+
force: 'true'
4543

46-
- uses: cloudposse/[email protected]
47-
id: write
44+
- name: 'Setup yq'
45+
uses: dcarbone/[email protected]
46+
with:
47+
version: v4.28.1
48+
download-compressed: true
49+
force: true
50+
51+
- shell: bash
52+
id: proxy
53+
run: |-
54+
JSON=$(echo "${{ inputs.outputs }}" | yq '. + {}' -o json | jq . -c -M -e)
55+
echo "result=${JSON}" >> $GITHUB_OUTPUT
56+
57+
- uses: cloudposse/[email protected]
58+
id: mask
4859
with:
4960
query: .${{ inputs.matrix-key == '' }}
5061
config: |-
5162
true:
52-
result:
53-
${{ inputs.outputs }}
63+
mask: ". + {}"
5464
false:
55-
result:
56-
${{ inputs.matrix-key || 'null' }}:
57-
${{ inputs.outputs }}
65+
mask: "{\"${{ inputs.matrix-key}}\": . + {}}"
66+
67+
- shell: bash
68+
id: write
69+
run: |-
70+
JSON=$(echo "${{ inputs.outputs }}" | yq '${{ steps.mask.outputs.mask }}' -o json | jq . -c -M -e)
71+
echo "result=${JSON}" >> $GITHUB_OUTPUT
5872
5973
- shell: bash
6074
if: ${{ inputs.outputs != '' && inputs.matrix-step-name != '' }}

0 commit comments

Comments
 (0)