|
1 | | -name: 🚀 Deploy vitepress to help.keycapsss.com |
| 1 | +name: 🚀 Build and deploy vitepress |
| 2 | + |
2 | 3 | on: |
3 | | - workflow_dispatch: |
4 | 4 | push: |
5 | 5 | branches: |
6 | | - - master # Triggers the action on push to the 'main' branch |
7 | | - # tags: |
8 | | - # - v*.*.* # Triggers the action on tag |
| 6 | + - main |
| 7 | + workflow_dispatch: # Allows manual trigger |
9 | 8 |
|
10 | 9 | jobs: |
11 | | - build: |
12 | | - name: 🚧 Build |
| 10 | + build-and-deploy: |
13 | 11 | runs-on: ubuntu-latest |
14 | 12 | steps: |
15 | | - - name: Get latest code |
16 | | - uses: actions/checkout@v4 |
| 13 | + - name: Checkout |
| 14 | + uses: actions/checkout@v5 |
17 | 15 | with: |
18 | | - fetch-depth: 0 |
| 16 | + fetch-depth: 0 # Not needed if lastUpdated is not enabled |
19 | 17 |
|
20 | | - - name: Setup Node.js |
21 | | - uses: actions/setup-node@v4 |
| 18 | + - name: Setup Node |
| 19 | + uses: actions/setup-node@v6 |
22 | 20 | with: |
23 | | - node-version: "24" |
24 | | - |
25 | | - - name: Get tag version |
26 | | - id: get_tag |
27 | | - run: echo "TAG_VERSION=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV |
28 | | - |
29 | | - - name: Set environment variables from GitHub Secrets |
30 | | - run: | |
31 | | - echo "FTP_HOST=${{ secrets.FTP_HOST }}" >> $GITHUB_ENV |
| 21 | + node-version: 24 |
| 22 | + cache: npm |
32 | 23 |
|
33 | 24 | - name: Install dependencies |
34 | | - run: npm install |
35 | | - |
36 | | - - name: Build Vitepress site |
37 | | - run: npm run docs:build # Assumes there's a build script in package.json |
38 | | - |
39 | | - - name: Upload artifacts |
40 | | - uses: actions/upload-artifact@v4 |
41 | | - with: |
42 | | - name: vitepress-dist |
43 | | - path: docs/.vitepress/dist/ |
44 | | - retention-days: 1 |
45 | | - |
46 | | - deploy: |
47 | | - name: 🚀 Deploy |
48 | | - needs: build |
49 | | - runs-on: ubuntu-latest |
50 | | - steps: |
51 | | - - name: Download artifacts |
52 | | - uses: actions/download-artifact@v4 |
53 | | - with: |
54 | | - name: vitepress-dist |
55 | | - path: dist/ |
| 25 | + run: npm ci |
56 | 26 |
|
57 | | - # - name: Clean target directory |
58 | | - # uses: appleboy/ssh-action@master |
59 | | - # with: |
60 | | - # host: ${{ secrets.SSH_HOST }} |
61 | | - # username: ${{ secrets.SSH_USERNAME }} |
62 | | - # key: ${{ secrets.SSH_PRIVATE_KEY }} |
63 | | - # port: ${{ secrets.SSH_PORT }} |
64 | | - # script: | |
65 | | - # rm -rf /data/coolify/services/pwogokkc8gggwc408s4kkos4/web/help.keycapsss.com/* |
| 27 | + - name: Build with VitePress |
| 28 | + run: npm run docs:build |
66 | 29 |
|
67 | | - - name: Upload files via SCP |
68 | | - uses: appleboy/scp-action@master |
| 30 | + - name: Deploy to dist branch |
| 31 | + uses: peaceiris/actions-gh-pages@v4 |
69 | 32 | with: |
70 | | - host: ${{ secrets.SSH_HOST }} |
71 | | - username: ${{ secrets.SSH_USERNAME }} |
72 | | - key: ${{ secrets.SSH_PRIVATE_KEY }} |
73 | | - port: ${{ secrets.SSH_PORT }} |
74 | | - source: "dist/*" |
75 | | - target: "/data/coolify/services/pwogokkc8gggwc408s4kkos4/web/help.keycapsss.com" |
76 | | - strip_components: 1 |
| 33 | + github_token: ${{ secrets.GITHUB_TOKEN }} |
| 34 | + publish_dir: ./docs/.vitepress/dist |
| 35 | + publish_branch: dist |
| 36 | + force_orphan: true # Keeps the dist branch clean without history |
0 commit comments