Skip to content

Commit 3c85658

Browse files
author
刘健
committed
Update .gitlab-ci.yml file
1 parent ba7022b commit 3c85658

1 file changed

Lines changed: 6 additions & 5 deletions

File tree

.gitlab-ci.yml

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@ stages:
2020

2121
sync_job:
2222
stage: sync
23+
variables:
24+
GITLAB_REPO: http://$DEPLOY_USER:$DEPLOY_TOKEN@gitlab.eolink.com/apipark/APIPark
25+
GIT_STRATEGY: none # 避免 CI 克隆 GitLab 仓库
2326
script:
2427
# 检查是否已有仓库缓存,若无则克隆
2528
- if [ ! -d "repo-cache" ]; then
@@ -30,20 +33,18 @@ sync_job:
3033
- git pull origin main
3134

3235
# 获取 GitLab main 分支的最新提交
33-
- git fetch http://$DEPLOY_USER:$DEPLOY_TOKEN@gitlab.eolink.com/apipark/APIPark main:gitlab-main
34-
- DIFF=$(git diff "$GITHUB_BRANCH" gitlab-main)
36+
- git fetch ${GITLAB_REPO} main:gitlab-main
37+
- DIFF=$(git diff main gitlab-main)
3538
# 比较 SHA,检查是否有更改
3639
- if [ -n "$DIFF" ]; then
3740
- echo "Differences detected, syncing to GitLab..."
3841
# 推送到 GitLab main 分支
39-
- git push "$GITLAB_REPO" "$GITHUB_BRANCH:$GITLAB_BRANCH"
42+
- git push "$GITLAB_REPO" "main:main"
4043
- else
4144
- echo "No differences found between GitHub and GitLab main branches."
4245
- fi
4346
# only:
4447
# - schedules
45-
variables:
46-
GIT_STRATEGY: none # 避免 CI 克隆 GitLab 仓库
4748
cache:
4849
key: repo-cache
4950
paths:

0 commit comments

Comments
 (0)