feat: add action #1
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
| name: Build and Deploy via SFTP | |
| on: | |
| push: | |
| branches: [ main, master ] | |
| workflow_dispatch: | |
| jobs: | |
| build-and-deploy: | |
| runs-on: ubuntu-latest | |
| # 只在指定仓库中运行 | |
| if: github.repository == 'langhuihui/m7s-website' | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: '18' | |
| cache: 'npm' | |
| - name: Install pnpm | |
| uses: pnpm/action-setup@v4 | |
| with: | |
| version: latest | |
| - name: Install dependencies | |
| run: pnpm install | |
| - name: Build project | |
| run: pnpm run build | |
| - name: Deploy to server via SFTP | |
| uses: SamKirkland/FTP-Deploy-Action@v4.3.5 | |
| with: | |
| server: ${{ secrets.SFTP_HOST }} | |
| username: ${{ secrets.SFTP_USERNAME }} | |
| password: ${{ secrets.SFTP_PASSWORD }} | |
| port: ${{ secrets.SFTP_PORT }} | |
| protocol: sftp | |
| local-dir: ./.vitepress/dist/ | |
| server-dir: ${{ secrets.SFTP_SERVER_DIR }} | |
| exclude: | | |
| **/.git* | |
| **/.git*/** | |
| **/node_modules/** | |
| .env |