mirror of
https://github.com/timeshiftsauce/CeruMusic.git
synced 2025-11-25 03:15:07 +08:00
Update sync-releases-to-webdav.yml
This commit is contained in:
63
.github/workflows/sync-releases-to-webdav.yml
vendored
63
.github/workflows/sync-releases-to-webdav.yml
vendored
@@ -1,34 +1,3 @@
|
||||
name: Sync Existing Releases to Alist
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
tag_name:
|
||||
description: '要同步的特定标签(如 v1.0.0),留空则同步所有版本'
|
||||
required: false
|
||||
default: ''
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
jobs:
|
||||
sync-releases-to-alist:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Install dependencies
|
||||
run: |
|
||||
sudo apt-get update
|
||||
sudo apt-get install -y curl jq
|
||||
|
||||
- name: Get all releases
|
||||
id: get-releases
|
||||
run: |
|
||||
response=$(curl -s \
|
||||
-H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
|
||||
-H "Accept: application/vnd.github.v3+json" \
|
||||
"https://api.github.com/repos/${{ github.repository }}/releases")
|
||||
echo "releases_json=$(echo "$response" | jq -c '.')" >> $GITHUB_OUTPUT
|
||||
|
||||
- name: Sync releases to Alist(自动登录 & 上传)
|
||||
run: |
|
||||
# ========== 1. 读取输入参数 ==========
|
||||
@@ -36,9 +5,9 @@ jobs:
|
||||
RELEASES_JSON='${{ steps.get-releases.outputs.releases_json }}'
|
||||
|
||||
# ========== 2. Alist 连接信息 ==========
|
||||
ALIST_URL="https://alist.shiqianjiang.cn" # https://pan.example.com
|
||||
ALIST_USER="${{ secrets.WEBDAV_USERNAME }}" # Alist 登录账号
|
||||
ALIST_PASS="${{ secrets.WEBDAV_PASSWORD }}" # Alist 登录密码
|
||||
ALIST_URL="${{ secrets.ALIST_URL }}" # https://pan.example.com
|
||||
ALIST_USER="${{ secrets.ALIST_USERNAME }}" # Alist 登录账号
|
||||
ALIST_PASS="${{ secrets.ALIST_PASSWORD }}" # Alist 登录密码
|
||||
ALIST_DIR="/lz/ceru" # 目标根目录
|
||||
|
||||
# ========== 3. 登录拿 token ==========
|
||||
@@ -103,24 +72,28 @@ jobs:
|
||||
continue
|
||||
}
|
||||
|
||||
# 组装远程路径
|
||||
# 组装远程路径(URL 编码)
|
||||
remote_path="$ALIST_DIR/$tag_name/$asset_name"
|
||||
file_path_encoded=$(printf %s "$remote_path" | jq -sRr @uri)
|
||||
echo "上传到 Alist: $remote_path"
|
||||
|
||||
# 调用 /api/fs/put 上传
|
||||
# 调用 /api/fs/put 上传(带 As-Task 异步)
|
||||
response=$(
|
||||
curl -s -X PUT "$ALIST_URL/api/fs/put" \
|
||||
-H "Authorization: $token" \
|
||||
-H "File-Path: $(echo -n "$remote_path" | base64 -w 0)" \
|
||||
-H "File-Path: $file_path_encoded" \
|
||||
-H "Content-Type: application/octet-stream" \
|
||||
-H "Content-Length: $actual_size" \
|
||||
-H "As-Task: true" \
|
||||
--data-binary @"$safe_filename"
|
||||
)
|
||||
code=$(echo "$response" | jq -r '.code // .status // empty')
|
||||
echo "==== 上传接口原始返回 ===="
|
||||
echo "$response"
|
||||
code=$(echo "$response" | jq -r '.code // empty')
|
||||
if [ "$code" = "200" ]; then
|
||||
echo "✅ Alist 上传成功: $asset_name"
|
||||
echo "✅ Alist 上传任务创建成功: $asset_name"
|
||||
else
|
||||
echo "❌ Alist 上传失败: $asset_name"
|
||||
echo "返回内容: $response"
|
||||
fi
|
||||
|
||||
rm -f "$safe_filename"
|
||||
@@ -136,13 +109,3 @@ jobs:
|
||||
-H "Authorization: $token" > /dev/null || true
|
||||
|
||||
echo "🎉 Alist 同步完成"
|
||||
|
||||
- name: Summary
|
||||
run: |
|
||||
echo "同步任务已完成!"
|
||||
echo "请检查 Alist 中的文件是否正确上传。"
|
||||
echo "如果遇到问题,请检查以下配置:"
|
||||
echo "1. ALIST_URL - Alist 服务器地址"
|
||||
echo "2. ALIST_USERNAME - Alist 登录账号"
|
||||
echo "3. ALIST_PASSWORD - Alist 登录密码"
|
||||
echo "4. GITHUB_TOKEN - GitHub 访问令牌"
|
||||
|
||||
Reference in New Issue
Block a user