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

This commit is contained in:
298977887 2024-10-29 00:22:14 +08:00
parent f4b82c11a4
commit 04b09d8d10
2 changed files with 23 additions and 22 deletions

View File

@ -17,13 +17,14 @@ jobs:
TZ: Asia/Shanghai TZ: Asia/Shanghai
run: date run: date
# 1. 读取 README.md 内容并清理特殊字符 # 1. 读取 README.md 内容
- name: 读取 README.md 内容 - name: 读取 README.md 内容
id: read_wp id: read_wp
run: | run: |
CONTENT=$(sed ':a;N;$!ba;s/\n/\\n/g' README.md) # 将换行符替换为 \n CONTENT=$(<README.md)
# JSON 转义并保存到环境变量
echo "wp_content<<EOF" >> $GITHUB_ENV echo "wp_content<<EOF" >> $GITHUB_ENV
echo "$CONTENT" >> $GITHUB_ENV echo "$CONTENT" | jq -Rs . >> $GITHUB_ENV
echo "EOF" >> $GITHUB_ENV echo "EOF" >> $GITHUB_ENV
# 2. 读取固件版本 DISTRIB_REVISION.txt # 2. 读取固件版本 DISTRIB_REVISION.txt
@ -48,30 +49,28 @@ jobs:
POST_STATUS: "draft" POST_STATUS: "draft"
run: | run: |
FORMATTED_TIME=$(TZ='Asia/Shanghai' date "+%Y年%m月%d日") FORMATTED_TIME=$(TZ='Asia/Shanghai' date "+%Y年%m月%d日")
JSON_PAYLOAD=$(jq -n \
--arg content "${{ env.wp_content }}" \ # 创建 JSON 数据内容,保持 README 内容的原始格式
--arg title "${FORMATTED_TIME}最新每天更新OpenWRT&LEDE x86/64 软路由精品稳定版固件下载含插件" \ JSON_PAYLOAD=$(cat <<EOF
--arg post_status "$POST_STATUS" \ {
--arg firmware_version "${{ env.firmware_version }}" \ "title": "${FORMATTED_TIME}最新每天更新OpenWRT&LEDE x86/64 软路由精品稳定版固件下载含插件",
--arg kernel_version "6.X" \ "description": ${{ env.wp_content }},
--arg file_size "1024MB" \ "post_status": "$POST_STATUS",
--arg update_time "$FORMATTED_TIME" \ "custom_fields": [
'{ {"key": "wb_dl_firmware_version", "value": "${{ env.firmware_version }}"},
title: $title, {"key": "wb_dl_kernel_version", "value": "6.X"},
description: $content, {"key": "wb_dl_file_size", "value": "1024MB"},
post_status: $post_status, {"key": "wb_dl_update_time", "value": "$FORMATTED_TIME"}
custom_fields: [ ]
{key: "wb_dl_firmware_version", value: $firmware_version}, }
{key: "wb_dl_kernel_version", value: $kernel_version}, EOF
{key: "wb_dl_file_size", value: $file_size},
{key: "wb_dl_update_time", value: $update_time}
]
}'
) )
# 更新 WordPress 文章
RESPONSE=$(curl -s -X POST "$WORDPRESS_URL" \ RESPONSE=$(curl -s -X POST "$WORDPRESS_URL" \
--header "Content-Type: application/json" \ --header "Content-Type: application/json" \
--user "$WORDPRESS_USERNAME:$WORDPRESS_PASSWORD" \ --user "$WORDPRESS_USERNAME:$WORDPRESS_PASSWORD" \
--data "$JSON_PAYLOAD") --data "$JSON_PAYLOAD")
# 检查响应状态
echo "$RESPONSE" | jq . || echo "更新失败" echo "$RESPONSE" | jq . || echo "更新失败"

2
DISTRIB_REVISION.txt Normal file
View File

@ -0,0 +1,2 @@
2024年09月24日10时34分更新
R24.9.18