This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Sample workflow for building and deploying a Nuxt site to GitHub Pages | |
| # | |
| # To get started with Nuxt see: https://nuxtjs.org/docs/get-started/installation | |
| # | |
| name: Deploy Nuxt site to Tencent Cloud | |
| on: | |
| # Runs on pushes targeting the default branch | |
| push: | |
| branches: ["main"] | |
| # Allows you to run this workflow manually from the Actions tab | |
| workflow_dispatch: | |
| jobs: | |
| # Build job | |
| build: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Detect package manager | |
| id: detect-package-manager | |
| run: | | |
| if [ -f "${{ github.workspace }}/yarn.lock" ]; then | |
| echo "manager=yarn" >> $GITHUB_OUTPUT | |
| echo "command=install" >> $GITHUB_OUTPUT | |
| exit 0 | |
| elif [ -f "${{ github.workspace }}/package.json" ]; then | |
| echo "manager=npm" >> $GITHUB_OUTPUT | |
| echo "command=ci" >> $GITHUB_OUTPUT | |
| exit 0 | |
| else | |
| echo "Unable to determine package manager" | |
| exit 1 | |
| fi | |
| - name: Setup Node | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: "20" | |
| cache: ${{ steps.detect-package-manager.outputs.manager }} | |
| - name: Restore cache | |
| uses: actions/cache@v4 | |
| with: | |
| path: | | |
| dist | |
| .nuxt | |
| key: ${{ runner.os }}-nuxt-build-${{ hashFiles('dist') }} | |
| restore-keys: | | |
| ${{ runner.os }}-nuxt-build- | |
| - name: Install dependencies | |
| run: ${{ steps.detect-package-manager.outputs.manager }} ${{ steps.detect-package-manager.outputs.command }} | |
| - name: Static HTML export with Nuxt | |
| run: ${{ steps.detect-package-manager.outputs.manager }} run generate | |
| - name: Deploy to Tencent Cloud | |
| id: deploy | |
| uses: appleboy/[email protected] | |
| with: | |
| host: ${{ secrets.SERVER_HOST }} | |
| username: ${{ secrets.SERVER_USERNAME }} | |
| password: ${{ secrets.SERVER_PASSWORD }} | |
| port: 22 | |
| source: "app/.output/public/**" | |
| target: "/www/wwwroot/1s.design" | |
| rm: false | |
| strip_components: 3 | |
| overwrite: true | |
| command_timeout: "10m" | |
| timeout: "10m" | |
| debug: true | |
| - name: Send Feishu Notification | |
| if: steps.deploy.outcome == 'success' | |
| run: | | |
| curl -X POST ${{ secrets.FEISHU_WEBHOOK_URL }} \ | |
| -H "Content-Type: application/json" \ | |
| -d '{ | |
| "msg_type": "text", | |
| "content": { | |
| "text": "🎉 衣设前端nuxt项目部署成功!\n\n📌 部署信息:\n• 环境:生产环境\n• 分支:main\n• 时间:'"$(date +'%Y-%m-%d %H:%M:%S')"'\n• 服务器:'"${{ secrets.SERVER_HOST }}"'\n\n✨ 静态文件已成功部署到 /www/wwwroot/1s.design" | |
| } | |
| }' | |
| - name: Send Failure Notification | |
| if: steps.deploy.outcome == 'failure' | |
| run: | | |
| curl -X POST ${{ secrets.FEISHU_WEBHOOK_URL }} \ | |
| -H "Content-Type: application/json" \ | |
| -d '{ | |
| "msg_type": "text", | |
| "content": { | |
| "text": "❌ 衣设前端nuxt项目部署失败!\n分支: main\n时间: '"$(date +'%Y-%m-%d %H:%M:%S')"'" | |
| } | |
| }' |