Skip to content

Commit 70377d7

Browse files
committed
添加GitHub Actions自动部署工作流和自定义404页面
1 parent 4e2da37 commit 70377d7

File tree

2 files changed

+96
-0
lines changed

2 files changed

+96
-0
lines changed

.github/workflows/deploy.yml

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
name: Deploy to GitHub Pages
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
workflow_dispatch: # 允许手动触发
8+
9+
jobs:
10+
build-and-deploy:
11+
runs-on: ubuntu-latest
12+
permissions:
13+
contents: write # 明确指定需要写入权限
14+
concurrency:
15+
group: ${{ github.workflow }}-${{ github.ref }} # 确保不会同时运行多个相同的工作流程
16+
steps:
17+
- name: Checkout 🛎️
18+
uses: actions/checkout@v3
19+
20+
- name: Setup Node.js
21+
uses: actions/setup-node@v3
22+
with:
23+
node-version: '18'
24+
cache: 'npm'
25+
26+
- name: Install dependencies
27+
run: npm ci
28+
29+
- name: Build
30+
run: npm run build
31+
env:
32+
CI: false # 避免将警告视为错误
33+
34+
- name: Deploy 🚀
35+
uses: JamesIves/github-pages-deploy-action@v4
36+
with:
37+
folder: build # React 默认的构建输出目录
38+
branch: gh-pages # 部署到的分支
39+
clean: true # 清理旧文件
40+
token: ${{ secrets.GITHUB_TOKEN }} # 使用GitHub自动生成的token

public/404.html

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<meta charset="utf-8">
5+
<title>移动零算法可视化 - 页面未找到</title>
6+
<meta name="viewport" content="width=device-width, initial-scale=1">
7+
<style>
8+
body {
9+
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
10+
margin: 0;
11+
padding: 0;
12+
display: flex;
13+
justify-content: center;
14+
align-items: center;
15+
height: 100vh;
16+
text-align: center;
17+
background-color: #f8f9fa;
18+
color: #343a40;
19+
}
20+
.container {
21+
max-width: 500px;
22+
padding: 2rem;
23+
}
24+
h1 {
25+
font-size: 3rem;
26+
margin-bottom: 1rem;
27+
color: #007bff;
28+
}
29+
p {
30+
font-size: 1.2rem;
31+
margin-bottom: 2rem;
32+
}
33+
a {
34+
display: inline-block;
35+
background-color: #007bff;
36+
color: white;
37+
padding: 0.75rem 1.5rem;
38+
text-decoration: none;
39+
border-radius: 4px;
40+
font-weight: bold;
41+
transition: background-color 0.3s;
42+
}
43+
a:hover {
44+
background-color: #0056b3;
45+
}
46+
</style>
47+
</head>
48+
<body>
49+
<div class="container">
50+
<h1>404</h1>
51+
<p>抱歉,您访问的页面不存在。</p>
52+
<p>Sorry, the page you are looking for could not be found.</p>
53+
<a href="/leetcode-283-move-zeroes/">返回首页 / Back to Home</a>
54+
</div>
55+
</body>
56+
</html>

0 commit comments

Comments
 (0)