Skip to content

Commit

Permalink
update workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
zzzhizhia committed Jan 5, 2025
1 parent 6f98c41 commit b50a3d5
Showing 1 changed file with 21 additions and 18 deletions.
39 changes: 21 additions & 18 deletions .github/workflows/deploy-public.yml
Original file line number Diff line number Diff line change
Expand Up @@ -89,30 +89,33 @@ jobs:
git commit -m "Initial public branch from main ${COMMIT_HASH}"
git push origin public
else
# 确保临时目录存在
mkdir -p temp_public
# 保存构建产物到临时目录
mkdir -p "${RUNNER_TEMP}/public_content"
cp -r public/* "${RUNNER_TEMP}/public_content/"
# 保存构建产物
cp -r public/* temp_public/
# 切换分支
# 切换到 public 分支
git fetch origin public
git checkout public || git checkout -b public --track origin/public
if git rev-parse --verify origin/public >/dev/null 2>&1; then
git switch public
else
git switch --orphan public
git commit --allow-empty -m "Initial empty commit"
fi
# 清理当前目录(保留 .git)
find . -mindepth 1 -maxdepth 1 ! -name '.git' -exec rm -rf {} +
# 清理工作目录
git rm -rf .
git clean -fdx
# 恢复构建产物
cp -r temp_public/* .
rm -rf temp_public
cp -r "${RUNNER_TEMP}/public_content/"* .
rm -rf "${RUNNER_TEMP}/public_content"
git add .
if git diff --staged --quiet; then
# 提交更改
git add -A
if ! git diff --staged --quiet; then
git commit -m "Update from main ${COMMIT_HASH}" -m "Source commit message:" -m "${COMMIT_MSG}"
git push origin public
else
echo "No changes detected"
exit 0
fi
git commit -m "Update from main ${COMMIT_HASH}" -m "Source commit message:" -m "${COMMIT_MSG}"
git push origin public
fi

0 comments on commit b50a3d5

Please sign in to comment.