This commit is contained in:
parent
6b78b01d1a
commit
f4b82c11a4
38
.github/workflows/发布wordpress文章.yml
vendored
38
.github/workflows/发布wordpress文章.yml
vendored
@ -17,11 +17,11 @@ 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=$(<README.md)
|
CONTENT=$(sed ':a;N;$!ba;s/\n/\\n/g' README.md) # 将换行符替换为 \n
|
||||||
echo "wp_content<<EOF" >> $GITHUB_ENV
|
echo "wp_content<<EOF" >> $GITHUB_ENV
|
||||||
echo "$CONTENT" >> $GITHUB_ENV
|
echo "$CONTENT" >> $GITHUB_ENV
|
||||||
echo "EOF" >> $GITHUB_ENV
|
echo "EOF" >> $GITHUB_ENV
|
||||||
@ -48,26 +48,30 @@ 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=$(cat <<EOF
|
JSON_PAYLOAD=$(jq -n \
|
||||||
{
|
--arg content "${{ env.wp_content }}" \
|
||||||
"title": "${FORMATTED_TIME}最新每天更新OpenWRT&LEDE x86/64 软路由精品稳定版固件下载含插件",
|
--arg title "${FORMATTED_TIME}最新每天更新OpenWRT&LEDE x86/64 软路由精品稳定版固件下载含插件" \
|
||||||
"description": "${{ env.wp_content }}",
|
--arg post_status "$POST_STATUS" \
|
||||||
"post_status": "$POST_STATUS",
|
--arg firmware_version "${{ env.firmware_version }}" \
|
||||||
"custom_fields": [
|
--arg kernel_version "6.X" \
|
||||||
{"key": "wb_dl_firmware_version", "value": "${{ env.firmware_version }}"},
|
--arg file_size "1024MB" \
|
||||||
{"key": "wb_dl_kernel_version", "value": "6.X"},
|
--arg update_time "$FORMATTED_TIME" \
|
||||||
{"key": "wb_dl_file_size", "value": "1024MB"},
|
'{
|
||||||
{"key": "wb_dl_update_time", "value": "$FORMATTED_TIME"}
|
title: $title,
|
||||||
]
|
description: $content,
|
||||||
}
|
post_status: $post_status,
|
||||||
EOF
|
custom_fields: [
|
||||||
|
{key: "wb_dl_firmware_version", value: $firmware_version},
|
||||||
|
{key: "wb_dl_kernel_version", value: $kernel_version},
|
||||||
|
{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 "更新失败"
|
||||||
|
Loading…
Reference in New Issue
Block a user