22
33source_code_platforms=(openwrt immortalwrt lede)
44
5-
6-
7- openwrt_value=' {"REPO_URL": "https://github.com/openwrt/openwrt.git","REPO_BRANCH": "openwrt-25.12","CONFIGS": "config/openwrt_config","DIY_P1_SH": "diy_script/openwrt_diy/diy-part1.sh","DIY_P2_SH": "diy_script/openwrt_diy/diy-part2.sh","DIY_P3_SH": "diy_script/openwrt_diy/diy-part3.sh","OS": "ubuntu-latest"}'
8-
9- immortalwrt_value=' {"REPO_URL": "https://github.com/immortalwrt/immortalwrt.git","REPO_BRANCH": "openwrt-25.12","CONFIGS": "config/immortalwrt_config","DIY_P1_SH": "diy_script/immortalwrt_diy/diy-part1.sh","DIY_P2_SH": "diy_script/immortalwrt_diy/diy-part2.sh","DIY_P3_SH": "diy_script/immortalwrt_diy/diy-part3.sh","OS": "ubuntu-latest"}'
10-
11- lede_value=' {"REPO_URL": "https://github.com/coolsnowwolf/lede","REPO_BRANCH": "master","CONFIGS": "config/leanlede_config","DIY_P1_SH": "diy_script/lean_diy/diy-part1.sh","DIY_P2_SH": "diy_script/lean_diy/diy-part2.sh","DIY_P3_SH": "diy_script/lean_diy/diy-part3.sh","OS": "ubuntu-latest"}'
12-
5+ openwrt_value=' {
6+ "REPO_URL": "https://github.com/openwrt/openwrt.git",
7+ "REPO_BRANCH": "openwrt-25.12",
8+ "CONFIGS": "config/openwrt_config",
9+ "DIY_P1_SH": "diy_script/openwrt_diy/diy-part1.sh",
10+ "DIY_P2_SH": "diy_script/openwrt_diy/diy-part2.sh",
11+ "DIY_P3_SH": "diy_script/openwrt_diy/diy-part3.sh",
12+ "DIY_P4_SH": "diy_script/openwrt_diy/diy-part4.sh",
13+ "OS": "ubuntu-latest"
14+ }'
15+
16+ immortalwrt_value=' {
17+ "REPO_URL": "https://github.com/immortalwrt/immortalwrt.git",
18+ "REPO_BRANCH": "openwrt-25.12",
19+ "CONFIGS": "config/immortalwrt_config",
20+ "DIY_P1_SH": "diy_script/immortalwrt_diy/diy-part1.sh",
21+ "DIY_P2_SH": "diy_script/immortalwrt_diy/diy-part2.sh",
22+ "DIY_P3_SH": "diy_script/immortalwrt_diy/diy-part3.sh",
23+ "OS": "ubuntu-latest"
24+ }'
25+
26+ lede_value=' {
27+ "REPO_URL": "https://github.com/coolsnowwolf/lede",
28+ "REPO_BRANCH": "master",
29+ "CONFIGS": "config/leanlede_config",
30+ "DIY_P1_SH": "diy_script/lean_diy/diy-part1.sh",
31+ "DIY_P2_SH": "diy_script/lean_diy/diy-part2.sh",
32+ "DIY_P3_SH": "diy_script/lean_diy/diy-part3.sh",
33+ "OS": "ubuntu-latest"
34+ }'
1335
1436openwrt_platforms=(X86 R2S R3S R4S R4SE R5C R5S R6C R6S)
15-
1637immortalwrt_platforms=(X86 R2S R3S R4S R4SE R5C R5S R6C R6S R66S R68S)
17-
1838lede_platforms=(X86 R2S R3S R4S R4SE R5C R5S R6C R6S H28K H29K H66K H68K H69K R66S R68S)
1939
20-
21- copy_backgroundfiles_platforms=(X86 R5S R5C R4S R4SE R2S R2C H66K H68K H69K R66S R68S R_PI_3b R_PI_4b)
22-
2340matrix_json=" ["
2441source_matrix_json=" ["
2542
2643for source_platform in " ${source_code_platforms[@]} " ; do
27-
28-
2944 platforms_var=" ${source_platform} _platforms[@]"
3045 platforms=(" ${! platforms_var} " )
3146 value_var=" ${source_platform} _value"
@@ -38,11 +53,20 @@ for source_platform in "${source_code_platforms[@]}"; do
3853 done
3954done
4055
56+ # 去除末尾的逗号并闭合数组
4157matrix_json=" ${matrix_json% ,} ]"
4258source_matrix_json=" ${source_matrix_json% ,} ]"
4359
60+ # 【关键修复】使用 jq -c 将多行 JSON 压缩为紧凑的单行,确保能安全写入 GITHUB_OUTPUT
61+ COMPRESSED_MATRIX=$( echo " $matrix_json " | jq -c .)
62+ COMPRESSED_SOURCE=$( echo " $source_matrix_json " | jq -c .)
63+
64+ # 打印到控制台方便日志排错 (用 jq 格式化输出)
65+ echo " === Matrix JSON ==="
66+ echo " $COMPRESSED_MATRIX " | jq .
67+ echo " === Source Matrix JSON ==="
68+ echo " $COMPRESSED_SOURCE " | jq .
4469
45- echo $matrix_json
46- echo $source_matrix_json
47- echo " matrix=$matrix_json " >> $GITHUB_OUTPUT
48- echo " source_matrix_json=$source_matrix_json " >> $GITHUB_OUTPUT
70+ # 安全写入到 GITHUB_OUTPUT
71+ echo " matrix=$COMPRESSED_MATRIX " >> $GITHUB_OUTPUT
72+ echo " source_matrix_json=$COMPRESSED_SOURCE " >> $GITHUB_OUTPUT
0 commit comments