1028.yml
All checks were successful
发布wordpress文章 / generate_changelog (push) Successful in 7s

This commit is contained in:
298977887 2024-10-29 00:27:28 +08:00
parent 04b09d8d10
commit 7212f406c7

View File

@ -23,9 +23,8 @@ jobs:
run: |
CONTENT=$(<README.md)
# JSON 转义并保存到环境变量
echo "wp_content<<EOF" >> $GITHUB_ENV
echo "$CONTENT" | jq -Rs . >> $GITHUB_ENV
echo "EOF" >> $GITHUB_ENV
wp_content=$(echo "$CONTENT" | jq -Rs .)
echo "wp_content=$wp_content" >> $GITHUB_ENV
# 2. 读取固件版本 DISTRIB_REVISION.txt
- name: 读取 DISTRIB_REVISION.txt 中的固件版本
@ -47,23 +46,29 @@ jobs:
WORDPRESS_PASSWORD: ${{ secrets.WORDPRESS_PASSWORD }}
POST_ID: 829
POST_STATUS: "draft"
wp_content: ${{ env.wp_content }}
firmware_version: ${{ env.firmware_version }}
run: |
FORMATTED_TIME=$(TZ='Asia/Shanghai' date "+%Y年%m月%d日")
# 创建 JSON 数据内容,保持 README 内容的原始格式
JSON_PAYLOAD=$(cat <<EOF
{
"title": "${FORMATTED_TIME}最新每天更新OpenWRT&LEDE x86/64 软路由精品稳定版固件下载含插件",
"description": ${{ env.wp_content }},
"post_status": "$POST_STATUS",
"custom_fields": [
{"key": "wb_dl_firmware_version", "value": "${{ env.firmware_version }}"},
{"key": "wb_dl_kernel_version", "value": "6.X"},
{"key": "wb_dl_file_size", "value": "1024MB"},
{"key": "wb_dl_update_time", "value": "$FORMATTED_TIME"}
JSON_PAYLOAD=$(jq -n \
--arg title "${FORMATTED_TIME}最新每天更新OpenWRT&LEDE x86/64 软路由精品稳定版固件下载含插件" \
--argjson description "$wp_content" \
--arg post_status "$POST_STATUS" \
--arg firmware_version "$firmware_version" \
--arg formatted_time "$FORMATTED_TIME" \
'{
title: $title,
description: $description,
post_status: $post_status,
custom_fields: [
{key: "wb_dl_firmware_version", value: $firmware_version},
{key: "wb_dl_kernel_version", value: "6.X"},
{key: "wb_dl_file_size", value: "1024MB"},
{key: "wb_dl_update_time", value: $formatted_time}
]
}
EOF
}'
)
# 更新 WordPress 文章
@ -74,3 +79,4 @@ jobs:
# 检查响应状态
echo "$RESPONSE" | jq . || echo "更新失败"