Files
test/.gitea/workflows/prepare.yml
T
csh d73e06301a
Test Multi Jobs / first (push) Successful in 0s
Test Multi Jobs / second (push) Successful in 0s
Prepare / prepare (push) Successful in 12s
test: test
2026-07-17 17:58:30 +08:00

55 lines
1.5 KiB
YAML
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
name: Prepare
on:
push:
branches:
- main
workflow_dispatch:
jobs:
prepare:
runs-on: standard-ubuntu-22
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 完成"