fix: remove ambiguous unicode chars from workflow yaml
Sync to site1 / sync (push) Has been cancelled
Sync to site1 / sync (push) Has been cancelled
This commit is contained in:
@@ -1,17 +1,3 @@
|
|||||||
# ============================================================
|
|
||||||
# Gitea Actions Workflow: 同步 worldmodel 内容到 site1
|
|
||||||
# ============================================================
|
|
||||||
# 触发条件:push 到 main 分支
|
|
||||||
# 功能:将 worldmodel 仓库内容同步到 admin/site1 的
|
|
||||||
# content/posts/worldmodel/ 目录,并触发 Hugo 构建
|
|
||||||
#
|
|
||||||
# 前置条件(用户需手动操作):
|
|
||||||
# 在 Gitea 仓库 gaojie/worldmodel 的
|
|
||||||
# Settings → Secrets → Actions 里添加:
|
|
||||||
# Name: SITE1_PASSWORD
|
|
||||||
# Value: 你的 git.plantshero.com 账号 gaojie 的密码
|
|
||||||
# ============================================================
|
|
||||||
|
|
||||||
name: Sync to site1
|
name: Sync to site1
|
||||||
|
|
||||||
on:
|
on:
|
||||||
@@ -22,7 +8,6 @@ on:
|
|||||||
jobs:
|
jobs:
|
||||||
sync:
|
sync:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout worldmodel
|
- name: Checkout worldmodel
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
@@ -33,24 +18,17 @@ jobs:
|
|||||||
env:
|
env:
|
||||||
SITE1_PASSWORD: ${{ secrets.SITE1_PASSWORD }}
|
SITE1_PASSWORD: ${{ secrets.SITE1_PASSWORD }}
|
||||||
run: |
|
run: |
|
||||||
git clone \
|
git clone https://gaojie:${SITE1_PASSWORD}@git.plantshero.com/admin/site1.git /tmp/site1
|
||||||
https://gaojie:${SITE1_PASSWORD}@git.plantshero.com/admin/site1.git \
|
git -C /tmp/site1 remote set-url origin https://git.plantshero.com/admin/site1.git
|
||||||
/tmp/site1
|
|
||||||
# 立即清除 remote URL 中的凭据,避免凭据残留在 git 配置里
|
|
||||||
git -C /tmp/site1 remote set-url origin \
|
|
||||||
https://git.plantshero.com/admin/site1.git
|
|
||||||
|
|
||||||
- name: Sync content to site1
|
- name: Sync content
|
||||||
run: |
|
run: |
|
||||||
# 若目标目录已存在,先用 git rm 清理(保持 git 历史干净)
|
|
||||||
if [ -d /tmp/site1/content/posts/worldmodel ]; then
|
if [ -d /tmp/site1/content/posts/worldmodel ]; then
|
||||||
git -C /tmp/site1 rm -rf content/posts/worldmodel
|
git -C /tmp/site1 rm -rf content/posts/worldmodel
|
||||||
fi
|
fi
|
||||||
mkdir -p /tmp/site1/content/posts/worldmodel
|
mkdir -p /tmp/site1/content/posts/worldmodel
|
||||||
|
|
||||||
# rsync:排除 .git 及 .gitignore 中列出的产物
|
|
||||||
rsync -a \
|
rsync -a \
|
||||||
--exclude='.git/' \
|
--exclude='.git' \
|
||||||
--exclude='node_modules/' \
|
--exclude='node_modules/' \
|
||||||
--exclude='.venv/' \
|
--exclude='.venv/' \
|
||||||
--exclude='__pycache__/' \
|
--exclude='__pycache__/' \
|
||||||
@@ -75,24 +53,12 @@ jobs:
|
|||||||
cd /tmp/site1
|
cd /tmp/site1
|
||||||
git config user.name "gitea-actions"
|
git config user.name "gitea-actions"
|
||||||
git config user.email "actions@plantshero.com"
|
git config user.email "actions@plantshero.com"
|
||||||
|
|
||||||
git add content/posts/worldmodel
|
git add content/posts/worldmodel
|
||||||
|
|
||||||
# 若无变更则跳过,workflow 正常退出(exit 0)
|
|
||||||
if git diff --cached --quiet; then
|
if git diff --cached --quiet; then
|
||||||
echo "No changes to commit, skipping push."
|
echo "No changes to commit, skipping push."
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
git commit -m "chore(sync): sync worldmodel content @ ${{ github.sha }}"
|
||||||
git commit -m "chore(sync): 从 worldmodel 同步内容 @ ${{ github.sha }}"
|
git remote set-url origin https://gaojie:${SITE1_PASSWORD}@git.plantshero.com/admin/site1.git
|
||||||
|
|
||||||
# 推送时临时注入凭据
|
|
||||||
git remote set-url origin \
|
|
||||||
https://gaojie:${SITE1_PASSWORD}@git.plantshero.com/admin/site1.git
|
|
||||||
git push origin main
|
git push origin main
|
||||||
|
git remote set-url origin https://git.plantshero.com/admin/site1.git
|
||||||
# 推送完成后立即清除凭据
|
|
||||||
git remote set-url origin \
|
|
||||||
https://git.plantshero.com/admin/site1.git
|
|
||||||
|
|
||||||
echo "Sync complete. site1 post-receive hook will trigger Hugo build."
|
|
||||||
|
|||||||
Reference in New Issue
Block a user