Skip to content

Commit 5d6d949

Browse files
author
刘健
committed
Update .gitlab-ci.yml file
1 parent 3578182 commit 5d6d949

1 file changed

Lines changed: 11 additions & 15 deletions

File tree

.gitlab-ci.yml

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -27,23 +27,19 @@ sync_job:
2727
- fi
2828
- cd repo-cache
2929
# 获取 GitHub main 分支的最新提交
30-
- git fetch origin
31-
- GITHUB_SHA=$(git rev-parse origin/main)
32-
- echo http://$DEPLOY_USER:$DEPLOY_TOKEN@gitlab.eolink.com/apipark/APIPark.git
30+
- git pull origin main
31+
3332
# 获取 GitLab main 分支的最新提交
34-
- git remote remove gitlab
35-
- git remote add gitlab http://$DEPLOY_USER:$DEPLOY_TOKEN@gitlab.eolink.com/apipark/APIPark.git
36-
# - git remote add gitlab $CI_REPOSITORY_URL
37-
- git fetch gitlab
38-
- GITLAB_SHA=$(git rev-parse gitlab/main || echo "none")
33+
- git featch http://$DEPLOY_USER:$DEPLOY_TOKEN@gitlab.eolink.com/apipark/APIPark main:gitlab-main
34+
- DIFF=$(git diff "$GITHUB_BRANCH" gitlab-main)
3935
# 比较 SHA,检查是否有更改
40-
- if [ "$GITHUB_SHA" != "$GITLAB_SHA" ]; then
41-
- echo "Changes detected, syncing main branch..."
42-
- git push gitlab refs/remotes/origin/main:refs/heads/main
43-
- else
44-
- echo "No changes in main branch, skipping sync."
45-
- exit 0
46-
- fi
36+
- if [ -n "$DIFF" ]; then
37+
echo "Differences detected, syncing to GitLab..."
38+
# 推送到 GitLab main 分支
39+
git push "$GITLAB_REPO" "$GITHUB_BRANCH:$GITLAB_BRANCH"
40+
else
41+
echo "No differences found between GitHub and GitLab main branches."
42+
fi
4743
# only:
4844
# - schedules
4945
variables:

0 commit comments

Comments
 (0)