name: Deploy Frontend to 1Panel on: push: branches: - main # 🎯 或者是 master,看你的預設分支是哪一個 jobs: build-and-deploy: runs-on: ubuntu-22.04 steps: - name: Checkout Code uses: actions/checkout@v3 - name: Setup Node.js uses: actions/setup-node@v3 with: node-version: 22 # 🎯 對齊你的 Node 版本 - name: Install Dependencies run: npm install - name: Build Project run: npm run build # 🎯 編譯出 dist 資料夾 - name: Copy Files via Docker Volume Mount run: | # 用一個帶有掛載的臨時小容器,把目前工作區的 dist,直接同步到主機實體的 1Panel 目錄下 docker run --rm \ -v $(pwd)/dist:/src_dist \ -v /www/sites/fin-buddy.duckdns.org:/target_site \ alpine sh -c "mkdir -p /target_site/index && cp -r /src_dist/* /target_site/index/ && chmod -R 755 /target_site/index"