Files
Starlight_Lancher/.github/workflows/sync-cnb-source.yml
T
AxTps a8c630cbc8 chore(ci): Release 带更新说明并移除 CNB 源码镜像
- build-on-tag.yml 改为三段式:preflight 从 announcement catalog
  生成中英双语更新说明并创建带说明的 draft release,build 各平台
  仅上传产物,publish 在所有平台完成后把 draft 转为正式发布。
- 移除 sync-cnb-source.yml:不再向 CNB 镜像源码(避免打 tag 时
  触发额外流水线,以及默认上游仓库带来的误推风险)。
- catalog.ts 新增 1.0.1-beta1 版本公告,作为该版本 Release 说明
  的来源。
2026-09-25 22:19:19 +08:00

71 lines
2.1 KiB
YAML

name: Sync source to CNB
on:
push:
branches:
- '**'
tags:
- '**'
delete:
workflow_dispatch:
permissions:
contents: read
concurrency:
group: sync-cnb-source-${{ github.event_name == 'delete' && format('{0}/{1}', github.event.ref_type, github.event.ref) || github.ref }}
cancel-in-progress: false
jobs:
sync:
name: Sync Git ref
if: ${{ vars.ENABLE_CNB_SYNC == 'true' }}
runs-on: ubuntu-24.04
timeout-minutes: 5
steps:
- name: Check out source
if: ${{ github.event_name != 'delete' }}
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
fetch-depth: 0
filter: blob:none
- name: Push Git ref to CNB
env:
CNB_REPO_URL_HTTPS: ${{ secrets.CNB_REPO_URL_HTTPS }}
CNB_TOKEN: ${{ secrets.CNB_TOKEN }}
CNB_TOKEN_USER_NAME: ${{ secrets.CNB_TOKEN_USER_NAME }}
DELETED_REF: ${{ github.event.ref }}
DELETED_REF_TYPE: ${{ github.event.ref_type }}
run: |
set -euo pipefail
if [[ -z "${CNB_TOKEN:-}" || -z "${CNB_REPO_URL_HTTPS:-}" ]]; then
echo "CNB_TOKEN and CNB_REPO_URL_HTTPS must be configured"
exit 1
fi
cnb_url="${CNB_REPO_URL_HTTPS:-https://cnb.cool/axlmc/Axolotl.git}"
token_user="${CNB_TOKEN_USER_NAME:-cnb}"
auth="$(printf '%s:%s' "$token_user" "$CNB_TOKEN" | base64 -w0)"
git_cnb() {
git -c "http.extraHeader=Authorization: Basic $auth" "$@"
}
if [[ "$GITHUB_EVENT_NAME" == "delete" ]]; then
git init
if [[ "$DELETED_REF_TYPE" == "tag" ]]; then
ref="refs/tags/$DELETED_REF"
else
ref="refs/heads/$DELETED_REF"
fi
git_cnb push "$cnb_url" --delete "$ref"
else
if [[ "$GITHUB_REF" == refs/tags/* ]]; then
git fetch --force origin "$GITHUB_REF:$GITHUB_REF"
source_ref="$GITHUB_REF"
else
source_ref="HEAD"
fi
git_cnb push --force "$cnb_url" "$source_ref:$GITHUB_REF"
fi