CI 简化:移除 SCP artifact,Dockerfile 内 npm run build
This commit is contained in:
@@ -54,37 +54,21 @@ jobs:
|
|||||||
- name: Build
|
- name: Build
|
||||||
run: npm run build
|
run: npm run build
|
||||||
|
|
||||||
- name: Upload frontend build artifact
|
|
||||||
uses: actions/upload-artifact@v4
|
|
||||||
with:
|
|
||||||
name: frontend-next
|
|
||||||
path: |
|
|
||||||
frontend/.next
|
|
||||||
frontend/package.json
|
|
||||||
frontend/package-lock.json
|
|
||||||
frontend/next.config.mjs
|
|
||||||
frontend/public
|
|
||||||
!frontend/.next/cache
|
|
||||||
|
|
||||||
deploy:
|
deploy:
|
||||||
needs: [python-quality, frontend-quality]
|
needs: [python-quality, frontend-quality]
|
||||||
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
|
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
|
||||||
uses: actions/checkout@v4
|
|
||||||
|
|
||||||
- name: Download frontend build artifact
|
|
||||||
uses: actions/download-artifact@v4
|
|
||||||
with:
|
|
||||||
name: frontend-next
|
|
||||||
path: frontend
|
|
||||||
|
|
||||||
- name: Deploy to VPS
|
- name: Deploy to VPS
|
||||||
run: |
|
run: |
|
||||||
mkdir -p ~/.ssh
|
mkdir -p ~/.ssh
|
||||||
echo "${{ secrets.VPS_SSH_KEY }}" > ~/.ssh/id_rsa
|
echo "${{ secrets.VPS_SSH_KEY }}" > ~/.ssh/id_rsa
|
||||||
chmod 600 ~/.ssh/id_rsa
|
chmod 600 ~/.ssh/id_rsa
|
||||||
ssh -o StrictHostKeyChecking=accept-new ${{ secrets.VPS_USER }}@${{ secrets.VPS_HOST }} "cd /root/PolyWeather && git fetch origin main && git reset --hard origin/main && mkdir -p frontend"
|
ssh -o StrictHostKeyChecking=accept-new ${{ secrets.VPS_USER }}@${{ secrets.VPS_HOST }} "
|
||||||
scp -o StrictHostKeyChecking=accept-new -r frontend/.next frontend/package.json frontend/package-lock.json frontend/next.config.mjs ${{ secrets.VPS_USER }}@${{ secrets.VPS_HOST }}:/root/PolyWeather/frontend/
|
cd /root/PolyWeather
|
||||||
ssh -o StrictHostKeyChecking=accept-new ${{ secrets.VPS_USER }}@${{ secrets.VPS_HOST }} "cd /root/PolyWeather && docker compose down && docker compose up -d --build && sleep 10 && curl -s http://localhost:8000/healthz"
|
git fetch origin main && git reset --hard origin/main
|
||||||
|
docker compose down
|
||||||
|
docker compose up -d --build
|
||||||
|
sleep 10
|
||||||
|
curl -s http://localhost:8000/healthz
|
||||||
|
"
|
||||||
|
|||||||
+1
-1
@@ -37,7 +37,7 @@ services:
|
|||||||
NEXT_PUBLIC_SUPABASE_ANON_KEY: ''
|
NEXT_PUBLIC_SUPABASE_ANON_KEY: ''
|
||||||
NEXT_PUBLIC_SUPABASE_URL: ''
|
NEXT_PUBLIC_SUPABASE_URL: ''
|
||||||
context: ./frontend
|
context: ./frontend
|
||||||
dockerfile: prod.Dockerfile
|
dockerfile: Dockerfile
|
||||||
container_name: polyweather_frontend
|
container_name: polyweather_frontend
|
||||||
environment:
|
environment:
|
||||||
NEXT_PUBLIC_POLYWEATHER_API_BASE_URL: ${NEXT_PUBLIC_POLYWEATHER_API_BASE_URL:-}
|
NEXT_PUBLIC_POLYWEATHER_API_BASE_URL: ${NEXT_PUBLIC_POLYWEATHER_API_BASE_URL:-}
|
||||||
|
|||||||
Reference in New Issue
Block a user