test: rename workflows to .yml and gate downstream on prepare success
Test Multi Jobs / first (push) Successful in 1s
Test Multi Jobs / second (push) Successful in 1s
Prepare / prepare (push) Canceled after 0s

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
csh
2026-07-16 10:46:44 +08:00
co-authored by Claude Opus 4.8
parent dcb03831f3
commit 857e8d217a
3 changed files with 2 additions and 0 deletions
+54
View File
@@ -0,0 +1,54 @@
name: Prepare
on:
push:
branches:
- main
workflow_dispatch:
jobs:
prepare:
runs-on: ubuntu-latest
steps:
- name: 准备复用仓库(强制全量拉取 + 丢弃本地改动)
run: |
set -e
REPO_DIR=/tmp/reused-repo
REPO_URL="${{ github.server_url }}/${{ github.repository }}.git"
BRANCH="${{ github.ref_name }}"
echo "===== [$(date '+%F %T')] 开始准备仓库 ====="
echo "复用目录: $REPO_DIR"
echo "仓库地址: $REPO_URL"
echo "目标分支: $BRANCH"
if [ ! -d "$REPO_DIR/.git" ]; then
echo "首次使用,克隆仓库..."
git clone "$REPO_URL" "$REPO_DIR"
fi
cd "$REPO_DIR"
echo "----- 丢弃本地所有更改 -----"
git reset --hard
git clean -fdx
echo "----- 强制拉取最新(含 tag,删除已消失的远端 ref-----"
git remote set-url origin "$REPO_URL"
git fetch origin --prune --prune-tags --tags --force
echo "----- 强制对齐到远端分支 -----"
git checkout -B "$BRANCH" "origin/$BRANCH"
git reset --hard "origin/$BRANCH"
git clean -fdx
echo "----- 当前状态 -----"
git log -1 --oneline
echo "本地 tags:"
git tag
- name: 模拟准备耗时
run: |
echo "[$(date '+%F %T')] Prepare 开始 sleep 10s ..."
sleep 10
echo "[$(date '+%F %T')] Prepare 完成"