Files
CloudFlare-ImgBed/.github/workflows/sync-release.yml
2025-12-31 09:33:13 +08:00

38 lines
1.3 KiB
YAML

name: Sync Release to Frontend Repo
on:
release:
# 当 Release 被发布时触发
types: [published]
jobs:
sync-release:
runs-on: ubuntu-latest
steps:
- name: Sync Release to Another Repo
env:
# 你刚才存的 PAT
GH_TOKEN: ${{ secrets.RELEASE_SYNC_PAT }}
# 目标仓库,格式为 "用户名/仓库名"
TARGET_REPO: "MarSeventh/Sanyue-ImgHub"
# 从事件中提取的数据
TAG_NAME: ${{ github.event.release.tag_name }}
RELEASE_TITLE: ${{ github.event.release.name }}
RELEASE_BODY: ${{ github.event.release.body }}
IS_DRAFT: ${{ github.event.release.draft }}
IS_PRERELEASE: ${{ github.event.release.prerelease }}
run: |
# 使用 GitHub CLI (gh) 进行操作,这比写 curl 简单得多
# 根据源仓库的状态判断目标仓库是否也设为 draft 或 prerelease
ARGS=""
if [ "$IS_DRAFT" = "true" ]; then ARGS="$ARGS --draft"; fi
if [ "$IS_PRERELEASE" = "true" ]; then ARGS="$ARGS --prerelease"; fi
gh release create "$TAG_NAME" \
--repo "$TARGET_REPO" \
--title "$RELEASE_TITLE" \
--notes "$RELEASE_BODY" \
$ARGS