refactor: 彻底移除 docker compose,改用纯 docker 构建+重启部署
This commit is contained in:
+14
-10
@@ -3,27 +3,36 @@ name: Build and Deploy
|
||||
on:
|
||||
push:
|
||||
branches: [main]
|
||||
pull_request:
|
||||
branches: [main]
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Build Docker image
|
||||
run: |
|
||||
docker build -t awesome-index:latest .
|
||||
|
||||
deploy:
|
||||
needs: build
|
||||
if: github.ref == 'refs/heads/main'
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Copy files to server
|
||||
- name: Copy scripts to server
|
||||
uses: appleboy/scp-action@master
|
||||
with:
|
||||
host: 114.134.187.170
|
||||
username: root
|
||||
password: ${{ secrets.SERVER_PASSWORD }}
|
||||
source: "package.json,package-lock.json,src,public,.env.example,start.sh"
|
||||
source: "start.sh,.env.example"
|
||||
target: "/app/awesome/"
|
||||
|
||||
- name: Deploy and start service
|
||||
- name: Restart container
|
||||
uses: appleboy/ssh-action@master
|
||||
with:
|
||||
host: 114.134.187.170
|
||||
@@ -31,10 +40,5 @@ jobs:
|
||||
password: ${{ secrets.SERVER_PASSWORD }}
|
||||
script: |
|
||||
cd /app/awesome
|
||||
|
||||
# 如不存在 .env 则从 example 复制
|
||||
[ ! -f .env ] && cp .env.example .env
|
||||
|
||||
# 执行启动脚本
|
||||
chmod +x start.sh
|
||||
bash start.sh
|
||||
|
||||
Reference in New Issue
Block a user