|
10 | 10 | - "docs/**" |
11 | 11 | - "package*.json" |
12 | 12 |
|
13 | | -env: |
14 | | - SSH_HOST: ${{ secrets.DEV_DEPLOY_HOST }} |
15 | | - SSH_PORT: ${{ secrets.DEV_DEPLOY_PORT }} |
16 | | - SSH_USER: ${{ secrets.DEV_DEPLOY_USER }} |
17 | | - SSH_PASS: ${{ secrets.DEV_DEPLOY_PASS }} |
18 | | - SSH_DEST: /static |
19 | | - |
20 | 13 | concurrency: |
21 | 14 | group: dev |
22 | 15 | cancel-in-progress: true |
23 | 16 |
|
24 | 17 | jobs: |
25 | 18 | build: |
26 | 19 | name: "Build" |
27 | | - runs-on: ubuntu-latest |
28 | | - timeout-minutes: 10 |
29 | | - |
30 | 20 | if: ${{ !contains(github.event.head_commit.message, '#nodev') }} |
31 | | - |
32 | | - steps: |
33 | | - - name: "Checkout" |
34 | | - uses: actions/checkout@v5 |
35 | | - with: |
36 | | - fetch-depth: 0 |
37 | | - |
38 | | - - name: "Debug CTX github" |
39 | | - continue-on-error: true |
40 | | - env: |
41 | | - GITHUB_CTX: ${{ toJSON(github) }} |
42 | | - run: echo "$GITHUB_CTX" |
43 | | - |
44 | | - - name: "Setup Node 24" |
45 | | - uses: actions/setup-node@v6 |
46 | | - with: |
47 | | - node-version: 24 |
48 | | - |
49 | | - - name: "Install Dependencies" |
50 | | - run: | |
51 | | - npm ci |
52 | | -
|
53 | | - - name: "Run Build" |
54 | | - run: | |
55 | | - npm run build |
56 | | -
|
57 | | - - name: "Upload Artifact" |
58 | | - uses: actions/upload-artifact@v4 |
59 | | - with: |
60 | | - name: "artifact" |
61 | | - path: .vitepress/dist |
| 21 | + uses: cssnr/workflows/.github/workflows/npm-build.yaml@master |
| 22 | + permissions: |
| 23 | + contents: read |
| 24 | + with: |
| 25 | + build: "npm run build" |
| 26 | + path: ".vitepress/dist" |
62 | 27 |
|
63 | 28 | deploy: |
64 | 29 | name: "Deploy" |
65 | | - runs-on: ubuntu-latest |
66 | | - timeout-minutes: 5 |
| 30 | + uses: cssnr/workflows/.github/workflows/deploy-static.yaml@master |
67 | 31 | needs: build |
68 | | - |
69 | | - environment: |
70 | | - name: dev |
71 | | - url: https://dev-static.cssnr.com/ |
72 | | - |
73 | | - steps: |
74 | | - - name: "Download Artifact" |
75 | | - uses: actions/download-artifact@v5 |
76 | | - with: |
77 | | - name: "artifact" |
78 | | - |
79 | | - - name: "Debug Artifact" |
80 | | - continue-on-error: true |
81 | | - run: | |
82 | | - tree . |
83 | | -
|
84 | | - - name: "No Robots" |
85 | | - run: | |
86 | | - cat <<EOF > robots.txt |
87 | | - User-agent: * |
88 | | - Disallow: / |
89 | | - EOF |
90 | | -
|
91 | | - - name: "Setup SSH" |
92 | | - run: | |
93 | | - mkdir -p "${HOME}/.ssh" && chmod 0700 "${HOME}/.ssh" |
94 | | - ssh-keyscan -p "${{ env.SSH_PORT }}" -H "${{ env.SSH_HOST }}" \ |
95 | | - | tee -a "${HOME}/.ssh/known_hosts" |
96 | | -
|
97 | | - - name: "Deploy Artifact" |
98 | | - env: |
99 | | - SSHPASS: ${{ env.SSH_PASS }} |
100 | | - run: | |
101 | | - sshpass -e rsync -aPvh --delete -e 'ssh -p ${{ env.SSH_PORT }}' \ |
102 | | - ./ "${{ env.SSH_USER }}"@"${{ env.SSH_HOST }}":"${{ env.SSH_DEST }}" |
103 | | -
|
104 | | - - name: "Send Discord Notification" |
105 | | - uses: sarisia/actions-status-discord@v1 |
106 | | - with: |
107 | | - webhook: ${{ secrets.DISCORD_WEBHOOK }} |
108 | | - description: "https://dev-static.cssnr.com/" |
| 32 | + permissions: |
| 33 | + contents: read |
| 34 | + with: |
| 35 | + name: "dev" |
| 36 | + url: "https://dev-static.cssnr.com/" |
| 37 | + robots: true |
| 38 | + secrets: |
| 39 | + host: ${{ secrets.DEV_DEPLOY_HOST }} |
| 40 | + port: ${{ secrets.DEV_DEPLOY_PORT }} |
| 41 | + user: ${{ secrets.DEV_DEPLOY_USER }} |
| 42 | + pass: ${{ secrets.DEV_DEPLOY_PASS }} |
| 43 | + webhook: ${{ secrets.DISCORD_WEBHOOK }} |
0 commit comments