Commit 4e3549f2 by 罗启

Update .gitlab-ci.yml

parent 0be910a6
Pipeline #3148 passed with stage
in 1 minute 16 seconds
# 定义工作流的各个阶段 # .gitlab-ci.yml
stages:
- deploy
# 定义一个名为 "deploy_to_production" 的任务
deploy_to_production: deploy_to_production:
# 将这个任务归属到 "deploy" 阶段
stage: deploy stage: deploy
# 指定运行此任务的 Docker 镜像
image: alpine:latest image: alpine:latest
# 在主脚本运行前执行的准备工作 # --- 在这里添加 tags 部分 ---
tags:
- jarvis # 指定使用带有 "jarvis" 标签的 Runner
# ---------------------------
# before_script, script, only 这些部分保持不变
before_script: before_script:
- 'which ssh-agent || ( apk add --update --no-cache openssh-client )' - 'which ssh-agent || ( apk add --update --no-cache openssh-client )'
- eval $(ssh-agent -s) - eval $(ssh-agent -s)
...@@ -20,25 +19,15 @@ deploy_to_production: ...@@ -20,25 +19,15 @@ deploy_to_production:
- echo "$SSH_KNOWN_HOSTS" > ~/.ssh/known_hosts - echo "$SSH_KNOWN_HOSTS" > ~/.ssh/known_hosts
- chmod 644 ~/.ssh/known_hosts - chmod 644 ~/.ssh/known_hosts
# 任务的核心执行脚本
script: script:
- | - |
ssh -p $SSH_PORT $SSH_USER@$SSH_HOST " ssh -p $SSH_PORT $SSH_USER@$SSH_HOST "
echo '✅ 连接服务器成功,开始执行部署脚本...' echo '✅ 连接服务器成功,开始执行部署脚本...'
echo '进入项目目录: customer-recall'
cd customer-recall cd customer-recall
echo '正在从 GitLab (origin) 拉取最新代码...'
git pull origin master git pull origin master
echo '正在使用 Docker Compose 部署...'
docker compose up -d --build docker compose up -d --build
echo '🚀 部署流程执行完毕!' echo '🚀 部署流程执行完毕!'
" "
# 使用 "only" 关键字来控制触发分支
# 这段配置表示,这个任务只会在 "master" 分支上运行
only: only:
- master - master
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment