Skip to content

Commit fe87409

Browse files
committed
Use Ubusable Workflows
1 parent 5e820e0 commit fe87409

File tree

2 files changed

+26
-126
lines changed

2 files changed

+26
-126
lines changed

.github/workflows/dev.yaml

Lines changed: 19 additions & 84 deletions
Original file line numberDiff line numberDiff line change
@@ -10,99 +10,34 @@ on:
1010
- "docs/**"
1111
- "package*.json"
1212

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-
2013
concurrency:
2114
group: dev
2215
cancel-in-progress: true
2316

2417
jobs:
2518
build:
2619
name: "Build"
27-
runs-on: ubuntu-latest
28-
timeout-minutes: 10
29-
3020
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"
6227

6328
deploy:
6429
name: "Deploy"
65-
runs-on: ubuntu-latest
66-
timeout-minutes: 5
30+
uses: cssnr/workflows/.github/workflows/deploy-static.yaml@master
6731
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 }}

.github/workflows/pages.yaml

Lines changed: 7 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -21,49 +21,14 @@ concurrency:
2121
jobs:
2222
build:
2323
name: "Build"
24-
runs-on: ubuntu-latest
25-
timeout-minutes: 10
26-
2724
if: ${{ !contains(github.event.head_commit.message, '#nodeploy') }}
28-
29-
steps:
30-
- name: "Checkout"
31-
uses: actions/checkout@v5
32-
with:
33-
fetch-depth: 0
34-
35-
- name: "Debug CTX github"
36-
continue-on-error: true
37-
env:
38-
GITHUB_CTX: ${{ toJSON(github) }}
39-
run: echo "$GITHUB_CTX"
40-
41-
- name: "Setup Node 24"
42-
uses: actions/setup-node@v6
43-
with:
44-
node-version: 24
45-
46-
- name: "Configure Pages"
47-
uses: actions/configure-pages@v5
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 Pages Artifact"
58-
uses: actions/upload-pages-artifact@v4
59-
with:
60-
path: .vitepress/dist
61-
62-
- name: "Send Failure Notification"
63-
if: ${{ failure() }}
64-
uses: sarisia/actions-status-discord@v1
65-
with:
66-
webhook: ${{ secrets.DISCORD_WEBHOOK }}
25+
uses: cssnr/workflows/.github/workflows/npm-build.yaml@master
26+
permissions:
27+
contents: read
28+
with:
29+
build: "npm run build"
30+
path: ".vitepress/dist"
31+
pages: true
6732

6833
deploy:
6934
name: "Deploy"

0 commit comments

Comments
 (0)