feat:更新dev代码
This commit is contained in:
43
.gitea/workflows/deploy.yaml
Normal file
43
.gitea/workflows/deploy.yaml
Normal file
@@ -0,0 +1,43 @@
|
||||
name: Deploy To Dev
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- 'dev'
|
||||
|
||||
jobs:
|
||||
deploy:
|
||||
runs-on: gx-dev01
|
||||
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Copy specific directory to runner's host machine
|
||||
run: |
|
||||
TARGET_DIR="./dist"
|
||||
|
||||
# 检查 dist 目录是否存在
|
||||
if [ ! -d "$TARGET_DIR" ]; then
|
||||
echo "Error: The source directory '$TARGET_DIR' does not exist in the repository."
|
||||
# 如果目录不存在,报错并退出当前步骤
|
||||
exit 1
|
||||
fi
|
||||
cp -r ./dist/* /data/xsy-www/
|
||||
|
||||
- name: Find and restart the app container
|
||||
run: |
|
||||
# 1. 使用 docker ps 过滤包含 'xsy-lighttpd' 服务的容器
|
||||
# 2. 提取容器 ID 或名称
|
||||
CONTAINER_ID=$(docker ps -a --filter "name=xsy-lighttpd" --format "{{.ID}}")
|
||||
|
||||
if [ -z "$CONTAINER_ID" ]; then
|
||||
echo "Error: Could not find any container matching name 'app1'."
|
||||
exit 1
|
||||
else
|
||||
echo "Found container ID: $CONTAINER_ID. Restarting..."
|
||||
# 使用标准的 docker restart 命令
|
||||
docker restart "$CONTAINER_ID"
|
||||
echo "Container restarted successfully."
|
||||
fi
|
||||
|
||||
Reference in New Issue
Block a user