ci: 添加部署站点的Gitea工作流配置
Some checks failed
site-dist-deploy / build-and-deploy (push) Failing after 14s
Some checks failed
site-dist-deploy / build-and-deploy (push) Failing after 14s
This commit is contained in:
parent
31c1ecb612
commit
929e405aab
86
.gitea/workflows/docker.yml
Normal file
86
.gitea/workflows/docker.yml
Normal file
@ -0,0 +1,86 @@
|
||||
name: site-dist-deploy
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
- develop
|
||||
pull_request:
|
||||
branches:
|
||||
- main
|
||||
- develop
|
||||
|
||||
|
||||
env:
|
||||
VITE_APP_BASE_URL: https://h.hifast.biz
|
||||
SSH_HOST: ${{ vars.PRO_SSH_HOST }}
|
||||
SSH_PORT: ${{ vars.PRO_SSH_PORT }}
|
||||
SSH_USER: ${{ vars.PRO_SSH_USER }}
|
||||
SSH_PASSWORD: ${{ vars.PRO_SSH_PASSWORD }}
|
||||
DEPLOY_PATH: /var/www/down
|
||||
|
||||
jobs:
|
||||
build-and-deploy:
|
||||
runs-on: landing-hero-web01
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Build dist in Node container
|
||||
run: |
|
||||
docker run --rm -v "$PWD":/app -w /app node:20 bash -lc '
|
||||
npm ci
|
||||
echo "VITE_APP_BASE_URL=${VITE_APP_BASE_URL}" > .env.pord
|
||||
npm run build:prod
|
||||
tar -C dist -czf site_dist.tgz .
|
||||
'
|
||||
|
||||
- name: Prepare target directory
|
||||
uses: appleboy/ssh-action@v1.0.3
|
||||
with:
|
||||
host: ${{ env.SSH_HOST }}
|
||||
username: ${{ env.SSH_USER }}
|
||||
password: ${{ env.SSH_PASSWORD }}
|
||||
port: ${{ env.SSH_PORT }}
|
||||
timeout: 300s
|
||||
script: |
|
||||
mkdir -p ${{ env.DEPLOY_PATH }}
|
||||
rm -rf ${{ env.DEPLOY_PATH }}/*
|
||||
mkdir -p /tmp/ci-upload
|
||||
|
||||
- name: Upload dist archive
|
||||
uses: appleboy/scp-action@v0.1.7
|
||||
with:
|
||||
host: ${{ env.SSH_HOST }}
|
||||
username: ${{ env.SSH_USER }}
|
||||
password: ${{ env.SSH_PASSWORD }}
|
||||
port: ${{ env.SSH_PORT }}
|
||||
source: "site_dist.tgz"
|
||||
target: "/tmp/ci-upload"
|
||||
overwrite: true
|
||||
|
||||
- name: Extract archive to deploy path
|
||||
uses: appleboy/ssh-action@v1.0.3
|
||||
with:
|
||||
host: ${{ env.SSH_HOST }}
|
||||
username: ${{ env.SSH_USER }}
|
||||
password: ${{ env.SSH_PASSWORD }}
|
||||
port: ${{ env.SSH_PORT }}
|
||||
timeout: 300s
|
||||
script: |
|
||||
cd ${{ env.DEPLOY_PATH }}
|
||||
tar -xzf /tmp/ci-upload/site_dist.tgz
|
||||
rm -f /tmp/ci-upload/site_dist.tgz
|
||||
|
||||
- name: Reload Nginx
|
||||
uses: appleboy/ssh-action@v1.0.3
|
||||
with:
|
||||
host: ${{ env.SSH_HOST }}
|
||||
username: ${{ env.SSH_USER }}
|
||||
password: ${{ env.SSH_PASSWORD }}
|
||||
port: ${{ env.SSH_PORT }}
|
||||
timeout: 300s
|
||||
script: |
|
||||
nginx -t && nginx -s reload
|
||||
Loading…
x
Reference in New Issue
Block a user