From 3c0f243187861369451d00a19ced88d364b6c2bd Mon Sep 17 00:00:00 2001 From: kaixuanxu Date: Tue, 9 Dec 2025 13:20:29 +0800 Subject: [PATCH 1/6] fix: json --- .github/actions/validate-template/action.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/actions/validate-template/action.yml b/.github/actions/validate-template/action.yml index fb21b2f1..2a99f4d0 100644 --- a/.github/actions/validate-template/action.yml +++ b/.github/actions/validate-template/action.yml @@ -32,7 +32,9 @@ runs: INPUT_PATH: ${{ inputs.path }} INPUT_DIRECTORY: ${{ inputs.directory }} ACTION_PATH: ${{ github.action_path }} + shell: bash run: | result=$(deno run --allow-read "${ACTION_PATH}/src/main.ts" "${INPUT_PATH}" "${INPUT_DIRECTORY}") + # Escape special characters and ensure single-line JSON output + result=$(echo "$result" | jq -c '.') echo "result=${result}" >> "$GITHUB_OUTPUT" - shell: bash From 18f359285d6261cd51bec4f02dc6ef31047c4f0d Mon Sep 17 00:00:00 2001 From: kaixuanxu Date: Tue, 9 Dec 2025 13:27:02 +0800 Subject: [PATCH 2/6] fix: json --- .github/actions/validate-template/action.yml | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/.github/actions/validate-template/action.yml b/.github/actions/validate-template/action.yml index 2a99f4d0..c9763464 100644 --- a/.github/actions/validate-template/action.yml +++ b/.github/actions/validate-template/action.yml @@ -13,10 +13,10 @@ inputs: outputs: status: description: Validate status - value: ${{ fromJSON(steps.validate-template.outputs.result).status }} + value: ${{ steps.validate-template.outputs.status }} detail: description: Validate detail - value: ${{ fromJSON(steps.validate-template.outputs.result).detail }} + value: ${{ steps.validate-template.outputs.detail }} runs: using: composite @@ -35,6 +35,8 @@ runs: shell: bash run: | result=$(deno run --allow-read "${ACTION_PATH}/src/main.ts" "${INPUT_PATH}" "${INPUT_DIRECTORY}") - # Escape special characters and ensure single-line JSON output - result=$(echo "$result" | jq -c '.') - echo "result=${result}" >> "$GITHUB_OUTPUT" + # Parse JSON and extract status and detail separately + status=$(echo "$result" | jq -r '.status') + detail=$(echo "$result" | jq -r '.detail') + echo "status=${status}" >> "$GITHUB_OUTPUT" + echo "detail=${detail}" >> "$GITHUB_OUTPUT" From 511bd2e10651849d1eebd3348e52900ef02594f9 Mon Sep 17 00:00:00 2001 From: kaixuanxu Date: Tue, 9 Dec 2025 14:08:15 +0800 Subject: [PATCH 3/6] chore: fix sec, remove key --- .github/actions/validate-template/action.yml | 6 +++++- .github/workflows/validate-template.yml | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/.github/actions/validate-template/action.yml b/.github/actions/validate-template/action.yml index c9763464..b9a905ce 100644 --- a/.github/actions/validate-template/action.yml +++ b/.github/actions/validate-template/action.yml @@ -38,5 +38,9 @@ runs: # Parse JSON and extract status and detail separately status=$(echo "$result" | jq -r '.status') detail=$(echo "$result" | jq -r '.detail') + # Output status echo "status=${status}" >> "$GITHUB_OUTPUT" - echo "detail=${detail}" >> "$GITHUB_OUTPUT" + # Use multiline format for detail since it contains newlines + echo "detail<> "$GITHUB_OUTPUT" + echo "$detail" >> "$GITHUB_OUTPUT" + echo "EOF" >> "$GITHUB_OUTPUT" diff --git a/.github/workflows/validate-template.yml b/.github/workflows/validate-template.yml index ecee4933..b38c2f07 100644 --- a/.github/workflows/validate-template.yml +++ b/.github/workflows/validate-template.yml @@ -17,7 +17,7 @@ jobs: id: validate-template uses: ./.github/actions/validate-template with: - path: $GITHUB_WORKSPACE + path: ${{ github.workspace }} - name: Create comment if: ${{ steps.validate-template.outputs.status != 0 && !github.event.pull_request.head.repo.fork }} From a699203d0a227968f68840c671ce0486250db3e6 Mon Sep 17 00:00:00 2001 From: kaixuanxu Date: Tue, 9 Dec 2025 14:18:31 +0800 Subject: [PATCH 4/6] chore: fix sec, remove key --- .github/actions/validate-template/action.yml | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/.github/actions/validate-template/action.yml b/.github/actions/validate-template/action.yml index b9a905ce..cce4de92 100644 --- a/.github/actions/validate-template/action.yml +++ b/.github/actions/validate-template/action.yml @@ -13,10 +13,10 @@ inputs: outputs: status: description: Validate status - value: ${{ steps.validate-template.outputs.status }} + value: $VALIDATE_STATUS detail: description: Validate detail - value: ${{ steps.validate-template.outputs.detail }} + value: $VALIDATE_DETAIL runs: using: composite @@ -38,9 +38,6 @@ runs: # Parse JSON and extract status and detail separately status=$(echo "$result" | jq -r '.status') detail=$(echo "$result" | jq -r '.detail') - # Output status - echo "status=${status}" >> "$GITHUB_OUTPUT" - # Use multiline format for detail since it contains newlines - echo "detail<> "$GITHUB_OUTPUT" - echo "$detail" >> "$GITHUB_OUTPUT" - echo "EOF" >> "$GITHUB_OUTPUT" + # Store in GITHUB_ENV + echo "VALIDATE_STATUS=${status}" >> "$GITHUB_ENV" + echo "VALIDATE_DETAIL={detail}" >> "$GITHUB_ENV" From de79bcbdcb1bdbad5cb5b91d17bde16d91473300 Mon Sep 17 00:00:00 2001 From: kaixuanxu Date: Tue, 9 Dec 2025 14:24:01 +0800 Subject: [PATCH 5/6] chore: fix sec, remove key --- .github/actions/validate-template/action.yml | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/.github/actions/validate-template/action.yml b/.github/actions/validate-template/action.yml index cce4de92..5887ac8a 100644 --- a/.github/actions/validate-template/action.yml +++ b/.github/actions/validate-template/action.yml @@ -13,10 +13,10 @@ inputs: outputs: status: description: Validate status - value: $VALIDATE_STATUS + value: ${{ steps.validate-template.outputs.status }} detail: description: Validate detail - value: $VALIDATE_DETAIL + value: ${{ steps.validate-template.outputs.detail }} runs: using: composite @@ -38,6 +38,16 @@ runs: # Parse JSON and extract status and detail separately status=$(echo "$result" | jq -r '.status') detail=$(echo "$result" | jq -r '.detail') - # Store in GITHUB_ENV - echo "VALIDATE_STATUS=${status}" >> "$GITHUB_ENV" - echo "VALIDATE_DETAIL={detail}" >> "$GITHUB_ENV" + # Print for debugging + echo "::group::Validation Result" + echo "Status: ${status}" + echo "Detail:" + echo "$detail" + echo "::endgroup::" + # Output status and detail + echo "status=${status}" >> "$GITHUB_OUTPUT" + { + echo "detail<> "$GITHUB_OUTPUT" From 1cbc279cf80c3526a20f4e6eb29012bcb111b0ef Mon Sep 17 00:00:00 2001 From: kaixuanxu Date: Tue, 9 Dec 2025 14:34:50 +0800 Subject: [PATCH 6/6] chore: fix sec, remove key --- .github/actions/validate-template/action.yml | 21 ++++++-------------- .github/workflows/validate-template.yml | 8 -------- 2 files changed, 6 insertions(+), 23 deletions(-) diff --git a/.github/actions/validate-template/action.yml b/.github/actions/validate-template/action.yml index 5887ac8a..42fb0f0a 100644 --- a/.github/actions/validate-template/action.yml +++ b/.github/actions/validate-template/action.yml @@ -10,14 +10,6 @@ inputs: required: false description: Template directory -outputs: - status: - description: Validate status - value: ${{ steps.validate-template.outputs.status }} - detail: - description: Validate detail - value: ${{ steps.validate-template.outputs.detail }} - runs: using: composite steps: @@ -38,16 +30,15 @@ runs: # Parse JSON and extract status and detail separately status=$(echo "$result" | jq -r '.status') detail=$(echo "$result" | jq -r '.detail') - # Print for debugging + # Print validation result echo "::group::Validation Result" echo "Status: ${status}" echo "Detail:" echo "$detail" echo "::endgroup::" - # Output status and detail - echo "status=${status}" >> "$GITHUB_OUTPUT" - { - echo "detail<> "$GITHUB_OUTPUT" + exit 1 + fi diff --git a/.github/workflows/validate-template.yml b/.github/workflows/validate-template.yml index b38c2f07..22c47892 100644 --- a/.github/workflows/validate-template.yml +++ b/.github/workflows/validate-template.yml @@ -14,14 +14,6 @@ jobs: - uses: actions/checkout@v2 - name: Validate template - id: validate-template uses: ./.github/actions/validate-template with: path: ${{ github.workspace }} - - - name: Create comment - if: ${{ steps.validate-template.outputs.status != 0 && !github.event.pull_request.head.repo.fork }} - uses: peter-evans/create-or-update-comment@v1 - with: - issue-number: ${{ github.event.pull_request.number }} - body: ${{ steps.validate-template.outputs.detail }}