11name : Validate template
2-
32description : Validate ADF template
43
54inputs :
65 path :
76 required : true
8- description : Project root
7+ description : Project root path
98 directory :
109 required : false
1110 description : Template directory
11+ default : ' '
1212
1313outputs :
1414 status :
15- description : Validate status
15+ description : Validation exit code (0 = success, non-zero = failure)
1616 value : ${{ steps.validate-template.outputs.status }}
1717 detail :
18- description : Validate detail
18+ description : Validation details or error message
1919 value : ${{ steps.validate-template.outputs.detail }}
2020
2121runs :
2222 using : composite
2323 steps :
2424 - name : Setup Deno environment
25- uses : denoland/setup-deno@v1
25+ uses : denoland/setup-deno@v2
2626 with :
2727 deno-version : v1.x
2828
@@ -31,12 +31,41 @@ runs:
3131 env :
3232 INPUT_PATH : ${{ inputs.path }}
3333 INPUT_DIRECTORY : ${{ inputs.directory }}
34- ACTION_PATH : ${{ github.action_path }}
3534 shell : bash
3635 run : |
37- result=$(deno run --allow-read "${ACTION_PATH}/src/main.ts" "${INPUT_PATH}" "${INPUT_DIRECTORY}")
38- # Parse JSON and extract status and detail separately
39- status=$(echo "$result" | jq -r '.status')
40- detail=$(echo "$result" | jq -r '.detail')
36+ set -euo pipefail
37+
38+ # Run validation script
39+ if ! result=$(deno run --allow-read "${{ github.action_path }}/src/main.ts" "${INPUT_PATH}" "${INPUT_DIRECTORY}" 2>&1); then
40+ echo "status=1" >> "$GITHUB_OUTPUT"
41+ # Handle multi-line error output using heredoc
42+ {
43+ echo "detail<<EOF"
44+ echo "Deno execution failed: ${result}"
45+ echo "EOF"
46+ } >> "$GITHUB_OUTPUT"
47+ exit 0 # Don't fail the step, let caller handle status
48+ fi
49+
50+ # Validate JSON output
51+ if ! echo "$result" | jq empty 2>/dev/null; then
52+ echo "status=1" >> "$GITHUB_OUTPUT"
53+ {
54+ echo "detail<<EOF"
55+ echo "Invalid JSON output from validation script: ${result}"
56+ echo "EOF"
57+ } >> "$GITHUB_OUTPUT"
58+ exit 0
59+ fi
60+
61+ # Extract status and detail from JSON response
62+ status=$(echo "$result" | jq -r '.status // 1')
63+ detail=$(echo "$result" | jq -r '.detail // "No details provided"')
64+
4165 echo "status=${status}" >> "$GITHUB_OUTPUT"
42- echo "detail=${detail}" >> "$GITHUB_OUTPUT"
66+ # Handle potential multi-line detail content
67+ {
68+ echo "detail<<EOF"
69+ echo "${detail}"
70+ echo "EOF"
71+ } >> "$GITHUB_OUTPUT"
0 commit comments