fix:更新cicd
This commit is contained in:
38
.gitea/workflows/main.yml
Normal file
38
.gitea/workflows/main.yml
Normal file
@@ -0,0 +1,38 @@
|
||||
name: main
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [main]
|
||||
|
||||
jobs:
|
||||
main:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- name: 构建镜像
|
||||
run: |
|
||||
docker build -t react-app .
|
||||
docker save react-app | gzip > app.tar.gz
|
||||
|
||||
- name: 复制到服务器并运行
|
||||
uses: appleboy/scp-action@v0.1.5
|
||||
with:
|
||||
host: ${{ secrets.HOST }}
|
||||
username: ${{ secrets.USERNAME }}
|
||||
key: ${{ secrets.SSH_KEY }}
|
||||
source: "app.tar.gz"
|
||||
target: "/tmp/"
|
||||
|
||||
- name: 部署
|
||||
uses: appleboy/ssh-action@v1.0.3
|
||||
with:
|
||||
host: ${{ secrets.HOST }}
|
||||
username: ${{ secrets.USERNAME }}
|
||||
key: ${{ secrets.SSH_KEY }}
|
||||
script: |
|
||||
gunzip -c /tmp/app.tar.gz | docker load
|
||||
docker stop react-app 2>/dev/null || true
|
||||
docker rm react-app 2>/dev/null || true
|
||||
docker run -d --name react-app -p 8080:80 --restart always react-app
|
||||
rm -f /tmp/app.tar.gz
|
||||
10
Dockerfile
Normal file
10
Dockerfile
Normal file
@@ -0,0 +1,10 @@
|
||||
FROM node:20-alpine AS builder
|
||||
WORKDIR /app
|
||||
COPY package*.json ./
|
||||
RUN npm ci
|
||||
COPY . .
|
||||
RUN npm run build
|
||||
|
||||
FROM nginx:alpine
|
||||
COPY --from=builder /app/dist /usr/share/nginx/html
|
||||
EXPOSE 80
|
||||
Reference in New Issue
Block a user