dev:测试
This commit is contained in:
parent
14dd3c4153
commit
2488b5eea7
|
@ -0,0 +1,43 @@
|
|||
name: Deploy to Test
|
||||
on:
|
||||
push:
|
||||
branches: [dev] # 根据实际分支调整
|
||||
|
||||
jobs:
|
||||
deploy:
|
||||
runs-on: php7.3 # 必须同时包含两个标签
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Prepare SSH environment
|
||||
env:
|
||||
SSH_PRIVATE_KEY: ${{ secrets.TEST_SSH_KEY }} # 从 Gitea Secrets 读取私钥[2](@ref)
|
||||
run: |
|
||||
mkdir -p ~/.ssh
|
||||
echo "$SSH_PRIVATE_KEY" > ~/.ssh/id_rsa
|
||||
chmod 600 ~/.ssh/id_rsa
|
||||
# 将服务器指纹加入已知主机(规避首次连接确认)
|
||||
ssh-keyscan 43.142.97.39 >> ~/.ssh/known_hosts
|
||||
|
||||
- name: Sync code to server
|
||||
run: |
|
||||
rsync -avz --delete --exclude=".env" \
|
||||
./ deploy-user@43.142.97.39:/data/laravel_test/
|
||||
|
||||
- name: Deploy Docker containers
|
||||
run: |
|
||||
ssh -o StrictHostKeyChecking=no deploy-user@43.142.97.39 << 'EOF'
|
||||
cd /data/laravel_test
|
||||
|
||||
# 启动/重建 Docker 容器(需预置 docker-compose.yml)
|
||||
docker compose -p laravel_test down --volumes
|
||||
docker compose -p laravel_test up -d --build
|
||||
|
||||
# 在 PHP 容器内执行 Laravel 命令
|
||||
docker exec laravel_test-php-1 php artisan config:cache
|
||||
docker exec laravel_test-php-1 php artisan migrate --force
|
||||
|
||||
# 重载 Nginx 容器配置
|
||||
docker exec laravel_test-nginx-1 nginx -s reload
|
||||
EOF
|
|
@ -0,0 +1,23 @@
|
|||
version: '3.8'
|
||||
services:
|
||||
php:
|
||||
image: php:7.3-fpm
|
||||
volumes:
|
||||
- /data/laravel_test:/var/www/html
|
||||
working_dir: /var/www/html
|
||||
networks:
|
||||
- laravel_net
|
||||
|
||||
nginx:
|
||||
image: nginx:1.18
|
||||
ports:
|
||||
- "80:80"
|
||||
volumes:
|
||||
- /data/laravel_test:/var/www/html
|
||||
- ./nginx.conf:/etc/nginx/conf.d/default.conf
|
||||
networks:
|
||||
- laravel_net
|
||||
|
||||
networks:
|
||||
laravel_net:
|
||||
driver: bridge
|
|
@ -0,0 +1,15 @@
|
|||
server {
|
||||
listen 80;
|
||||
root /var/www/html/public;
|
||||
index index.php;
|
||||
|
||||
location / {
|
||||
try_files $uri $uri/ /index.php?$query_string;
|
||||
}
|
||||
|
||||
location ~ \.php$ {
|
||||
fastcgi_pass php:9000;
|
||||
include fastcgi_params;
|
||||
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue