forked from scjtqs/nextcloud-docker
-
Notifications
You must be signed in to change notification settings - Fork 0
/
.gitlab-ci.yml
36 lines (34 loc) · 1.57 KB
/
.gitlab-ci.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
## 需要准备的全局变量
## 1.SSH_PRIVATE_KEY 对应账号gitlab的私钥
stages: # List of stages for jobs, and their order of execution
- mergefromgithub
variables:
GITHUB_REPO: "https://github.com/scjtqs2/nextcloud-docker.git" # 改成你实际项目的上游地址
MAIN_BRANCH: "master" # 要同步的分支名
GITLAB_URL: "gitlab" # gitlab runner 内部连 gitlab的地址
mergefromgithub: # This job runs in the build stage, which runs first.
stage: mergefromgithub
before_script:
- 'which ssh-agent || ( apt-get update -qy && apt-get install openssh-client -qqy )'
- eval $(ssh-agent -s)
- echo "${SSH_PRIVATE_KEY}" | tr -d '\r' | ssh-add - > /dev/null # add ssh ke
- mkdir -p ~/.ssh
- chmod 700 ~/.ssh
- '[[ -f /.dockerenv ]] && echo -e "Host *\n\tStrictHostKeyChecking no\n\n" > ~/.ssh/config'
script:
- 'which git || ( apt-get update -qy && apt-get install git -qqy )'
- git config --global user.email "${GITLAB_USER_EMAIL}"
- git config --global user.name "${GITLAB_USER_NAME}"
- echo "add upstream"
- git remote add upstream $GITHUB_REPO
- echo "remote -v"
- git remote -v
- echo "fetch upstream"
- git fetch upstream
- echo "check main branch"
- git checkout origin/${MAIN_BRANCH}
- echo "merge upstream"
- git merge upstream/${MAIN_BRANCH}
- echo "push"
- git remote rm origin && git remote add origin "git@${GITLAB_URL}:${CI_PROJECT_PATH}.git"
- git push origin HEAD:${MAIN_BRANCH}