diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 2dcfdd8..56cb3c9 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,6 +1,7 @@ stages: - build - deploy + - push variables: ProjectPath: "mongo.games.com/game" @@ -13,6 +14,7 @@ default: build-job: stage: build script: + - git checkout $CI_COMMIT_REF_NAME # 拷贝到GOPATH - echo '拷贝到GOPATH' - cp -rfp ./* $GOPATH/src/$ProjectPath @@ -29,12 +31,16 @@ build-job: go build -v cd .. done < shell/programs.txt - only: - - develop deploy-job: stage: deploy script: + # 拉取 + - echo "拉取deploy" + - cd $GOPATH/src/$DeployPath + - git checkout $CI_COMMIT_REF_NAME + - git pull + # 拷贝data目录 - echo '拷贝data目录' - cd $GOPATH/src/$ProjectPath @@ -60,12 +66,14 @@ deploy-job: rm -rf $line/$line done < shell/programs.txt +push_job: + stage: push + script: # 提交代码 - echo '提交代码' - cd $GOPATH/src/$DeployPath + - git config user.email "ci@example.com" # 设置提交者的 email + - git config user.name "GitLab CI" # 设置提交者的名称 - git add . - - git commit -m "auto commit pipelineId\:$CI_PIPELINE_ID" - - git push origin develop - only: - - develop - + - git commit -m "auto commit pipelineId $CI_PIPELINE_ID" + - git push origin $CI_COMMIT_REF_NAME \ No newline at end of file