🔧 chore(tsl): add playbook sync workflow
This commit is contained in:
@@ -0,0 +1,68 @@
|
||||
name: 📦 Sync TSL Playbook
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
workflow_dispatch:
|
||||
|
||||
concurrency:
|
||||
group: sync-tsl-playbook-${{ github.repository }}
|
||||
cancel-in-progress: true
|
||||
|
||||
env:
|
||||
WORKSPACE_DIR: "/home/workspace"
|
||||
TARGET_BRANCH: "tsl-playbook"
|
||||
|
||||
jobs:
|
||||
sync:
|
||||
name: 📦 Build and publish tsl-playbook
|
||||
runs-on: ubuntu-22.04
|
||||
|
||||
steps:
|
||||
- name: 📥 准备仓库
|
||||
shell: bash
|
||||
run: |
|
||||
set -euo pipefail
|
||||
|
||||
echo "========================================"
|
||||
echo "📦 准备仓库到 WORKSPACE_DIR"
|
||||
echo "========================================"
|
||||
|
||||
REPO_NAME="${{ github.event.repository.name }}"
|
||||
TOKEN="${{ secrets.WORKFLOW }}"
|
||||
mkdir -p "$WORKSPACE_DIR"
|
||||
REPO_DIR="$(mktemp -d "$WORKSPACE_DIR/${REPO_NAME}.XXXXXX")"
|
||||
if [ -n "$TOKEN" ]; then
|
||||
REPO_URL="https://oauth2:${TOKEN}@${GITHUB_SERVER_URL#https://}/${GITHUB_REPOSITORY}.git"
|
||||
else
|
||||
REPO_URL="${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}.git"
|
||||
fi
|
||||
|
||||
git clone "$REPO_URL" "$REPO_DIR"
|
||||
|
||||
git -C "$REPO_DIR" fetch origin main
|
||||
git -C "$REPO_DIR" checkout -B main origin/main
|
||||
|
||||
git config --global --add safe.directory "$REPO_DIR"
|
||||
echo "REPO_DIR=$REPO_DIR" >> "$GITHUB_ENV"
|
||||
echo "✅ 仓库准备完成"
|
||||
|
||||
- name: 📦 Build and publish tsl-playbook
|
||||
shell: bash
|
||||
env:
|
||||
WORKFLOW: ${{ secrets.WORKFLOW }}
|
||||
run: |
|
||||
set -euo pipefail
|
||||
cd "$REPO_DIR"
|
||||
|
||||
echo "========================================"
|
||||
echo "🔨 Build bundle and sync $TARGET_BRANCH"
|
||||
echo "========================================"
|
||||
|
||||
TARGET_BRANCH="$TARGET_BRANCH" bash .gitea/ci/sync_tsl_playbook.sh
|
||||
|
||||
- name: 🧹 清理临时仓库
|
||||
if: always()
|
||||
run: |
|
||||
rm -rf "$REPO_DIR"
|
||||
Reference in New Issue
Block a user