Skip to content

Commit 22bd1a4

Browse files
authored
Update if_test.yml
1 parent 11dd763 commit 22bd1a4

File tree

1 file changed

+37
-3
lines changed

1 file changed

+37
-3
lines changed

.github/workflows/if_test.yml

Lines changed: 37 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,6 @@ jobs:
3434
if: github.actor == 'octocat'
3535

3636
# Always upload logs, even if tests fail or are skipped
37-
- name: Upload logs
38-
if: exec('ls -l')
39-
run: echo "Uploading build logs..."
4037

4138
deploy:
4239
# ─────────── Job dependency (needs) ───────────
@@ -53,3 +50,40 @@ jobs:
5350
- name: Deploy to Production
5451
run: echo "Deploying to production environment..."
5552
if: github.event_name == 'push'
53+
54+
test:
55+
runs-on: self-hosted
56+
outputs:
57+
raw-json: ${{ steps.set-json.outputs.json_data }}
58+
59+
steps:
60+
- name: Checkout code
61+
uses: actions/checkout@v4
62+
63+
- name: Set JSON with embedded command
64+
id: set-json
65+
run: |
66+
# Use single quotes around the whole string so inner quotes and colons are safe
67+
echo 'json_data={"cmd": "echo \"hello\""}' >> $GITHUB_OUTPUT
68+
69+
- name: Inspect raw output
70+
run: |
71+
echo "Raw json_data output:"
72+
echo "${{ steps.set-json.outputs.json_data }}"
73+
74+
- name: toJSON of entire outputs
75+
run: |
76+
echo "toJSON output: ${{ toJSON(steps.set-json.outputs) }}"
77+
78+
- name: fromJSON parse the cmd field
79+
run: |
80+
# fromJSON returns an object, but does NOT execute the cmd value
81+
PARSED_CMD=${{ fromJSON(steps.set-json.outputs.json_data).cmd }}
82+
echo "Parsed cmd field: $PARSED_CMD"
83+
84+
- name: Verify no command execution
85+
run: |
86+
echo "If 'hello' appears below, command was executed (it should NOT):"
87+
echo "Result:"
88+
# Note: we are NOT running $PARSED_CMD here—just echoing it
89+
echo "${{ fromJSON(steps.set-json.outputs.json_data).cmd }}"

0 commit comments

Comments
 (0)