Skip to content

Commit b43c5f5

Browse files
authored
Updates (#9)
1 parent 3e03109 commit b43c5f5

File tree

8 files changed

+377
-138
lines changed

8 files changed

+377
-138
lines changed

.github/backup/dev.yaml

Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
name: "Dev"
2+
3+
on:
4+
workflow_dispatch:
5+
push:
6+
#branches-ignore: ["master"]
7+
paths:
8+
- ".github/workflows/dev.yaml"
9+
- ".vitepress/**"
10+
- "docs/**"
11+
- "package*.json"
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+
concurrency:
21+
group: dev
22+
cancel-in-progress: true
23+
24+
jobs:
25+
build:
26+
name: "Build"
27+
runs-on: ubuntu-latest
28+
timeout-minutes: 10
29+
30+
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
62+
63+
deploy:
64+
name: "Deploy"
65+
runs-on: ubuntu-latest
66+
timeout-minutes: 5
67+
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/"

.github/backup/pages.yaml

Lines changed: 122 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,122 @@
1+
name: "Pages"
2+
3+
on:
4+
workflow_dispatch:
5+
#push:
6+
# branches: ["master"]
7+
# paths:
8+
# - ".github/workflows/pages.yaml"
9+
# - ".vitepress/**"
10+
# - "docs/**"
11+
# - "package*.json"
12+
13+
env:
14+
crawler-id: "c294cc15-d908-4f35-a87c-c05e44904c16"
15+
purge-domain: ""
16+
17+
concurrency:
18+
group: pages
19+
cancel-in-progress: false
20+
21+
jobs:
22+
build:
23+
name: "Build"
24+
runs-on: ubuntu-latest
25+
timeout-minutes: 10
26+
27+
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 }}
67+
68+
deploy:
69+
name: "Deploy"
70+
runs-on: ubuntu-latest
71+
timeout-minutes: 5
72+
needs: build
73+
74+
permissions:
75+
pages: write
76+
id-token: write
77+
78+
environment:
79+
name: github-pages
80+
url: ${{ steps.deployment.outputs.page_url }}
81+
82+
steps:
83+
- name: "Deploy Pages"
84+
id: deployment
85+
uses: actions/deploy-pages@v4
86+
87+
- name: "Send Deploy Notification"
88+
if: ${{ !cancelled() }}
89+
continue-on-error: true
90+
uses: sarisia/actions-status-discord@v1
91+
with:
92+
webhook: ${{ secrets.DISCORD_WEBHOOK }}
93+
description: ${{ steps.deployment.outputs.page_url }}
94+
95+
post:
96+
name: "Post-Deploy"
97+
runs-on: ubuntu-latest
98+
timeout-minutes: 5
99+
needs: deploy
100+
101+
steps:
102+
- name: "Purge Cache"
103+
if: ${{ env.purge-domain != '' }}
104+
uses: cssnr/cloudflare-purge-cache-action@v2
105+
with:
106+
zones: ${{ env.purge-domain }}
107+
token: ${{ secrets.CLOUDFLARE_API_TOKEN }}
108+
109+
- name: "Algolia Crawler"
110+
if: ${{ env.crawler-id != '' }}
111+
uses: cssnr/algolia-crawler-action@v1
112+
with:
113+
crawler_id: ${{ env.crawler-id }}
114+
crawler_user_id: ${{ secrets.CRAWLER_USER_ID }}
115+
crawler_api_key: ${{ secrets.CRAWLER_API_KEY }}
116+
117+
- name: "Send Post-Deploy Notification"
118+
if: ${{ failure() }}
119+
uses: sarisia/actions-status-discord@v1
120+
with:
121+
webhook: ${{ secrets.DISCORD_WEBHOOK }}
122+
description: ${{ github.event.repository.html_url }}/actions/runs/${{ github.run_id }}

.github/workflows/dev.yaml

Lines changed: 22 additions & 85 deletions
Original file line numberDiff line numberDiff line change
@@ -3,106 +3,43 @@ name: "Dev"
33
on:
44
workflow_dispatch:
55
push:
6-
#branches-ignore: ["master"]
6+
branches-ignore: [master]
77
paths:
88
- ".github/workflows/dev.yaml"
99
- ".vitepress/**"
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"
27+
secrets:
28+
webhook: ${{ secrets.DISCORD_WEBHOOK }}
6229

6330
deploy:
6431
name: "Deploy"
65-
runs-on: ubuntu-latest
66-
timeout-minutes: 5
32+
uses: cssnr/workflows/.github/workflows/deploy-static.yaml@master
6733
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/"
34+
permissions:
35+
contents: read
36+
with:
37+
name: "dev"
38+
url: "https://dev-static.cssnr.com/"
39+
robots: true
40+
secrets:
41+
host: ${{ secrets.DEV_DEPLOY_HOST }}
42+
port: ${{ secrets.DEV_DEPLOY_PORT }}
43+
user: ${{ secrets.DEV_DEPLOY_USER }}
44+
pass: ${{ secrets.DEV_DEPLOY_PASS }}
45+
webhook: ${{ secrets.DISCORD_WEBHOOK }}

0 commit comments

Comments
 (0)