Skip to content

Commit 6acd5aa

Browse files
Merge pull request #31 from SteveLin100132/feat/official-website
chore: Implement CI/CD workflows for GitHub Pages deployment and update master.yml for pull request handling
2 parents afe3608 + e14fcb6 commit 6acd5aa

File tree

4 files changed

+78
-4
lines changed

4 files changed

+78
-4
lines changed
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
name: Deploy Website to GitHub Pages
2+
3+
on:
4+
push:
5+
branches:
6+
- master # 當推送到 master 分支時觸發
7+
paths:
8+
- "website/**" # 只有當 website 目錄有變更時才觸發
9+
workflow_dispatch: # 允許手動觸發
10+
11+
# 設定 GITHUB_TOKEN 的權限
12+
permissions:
13+
contents: read
14+
pages: write
15+
id-token: write
16+
17+
# 確保同時只有一個部署任務在執行
18+
concurrency:
19+
group: "pages"
20+
cancel-in-progress: false
21+
22+
jobs:
23+
build:
24+
runs-on: ubuntu-latest
25+
26+
steps:
27+
- name: Checkout repository
28+
uses: actions/checkout@v4
29+
30+
- name: Setup Node.js
31+
uses: actions/setup-node@v4
32+
with:
33+
node-version: "18"
34+
cache: "npm"
35+
cache-dependency-path: "website/package-lock.json"
36+
37+
- name: Install dependencies
38+
run: |
39+
cd website
40+
npm i
41+
42+
- name: Build website
43+
run: |
44+
cd website
45+
npm run build
46+
47+
- name: Setup Pages
48+
uses: actions/configure-pages@v5
49+
50+
- name: Upload artifact
51+
uses: actions/upload-pages-artifact@v3
52+
with:
53+
path: "./website/dist"
54+
55+
deploy:
56+
environment:
57+
name: github-pages
58+
url: ${{ steps.deployment.outputs.page_url }}
59+
runs-on: ubuntu-latest
60+
needs: build
61+
62+
steps:
63+
- name: Deploy to GitHub Pages
64+
id: deployment
65+
uses: actions/deploy-pages@v4

.github/workflows/master.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
name: CI - master
22

33
on:
4-
push:
4+
pull_request:
5+
types: [closed]
56
branches:
67
- "master"
78

@@ -54,6 +55,7 @@ jobs:
5455
bump-version:
5556
name: Bump Version and Update GitHub Variable
5657
runs-on: ubuntu-latest
58+
if: github.event.pull_request.merged == true && contains(github.event.pull_request.labels.*.name, 'build')
5759
outputs:
5860
new_version: ${{ steps.bump.outputs.new_version }}
5961
# needs: unit-test # 等 unit-test 成功才執行
@@ -87,6 +89,7 @@ jobs:
8789
build-image:
8890
name: Build and Push Docker Image
8991
runs-on: ubuntu-latest
92+
if: github.event.pull_request.merged == true && contains(github.event.pull_request.labels.*.name, 'build')
9093
needs:
9194
# - unit-test # 等 unit-test 成功才執行
9295
- bump-version # 等 bump-version 成功才執行

website/index.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
<!doctype html>
1+
<!DOCTYPE html>
22
<html lang="en">
33
<head>
44
<meta charset="UTF-8" />
5-
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
5+
<link rel="icon" type="image/svg+xml" href="./logo.svg" />
66
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
7-
<title>Vite + React + TS</title>
7+
<title>Notion Chart Generator</title>
88
</head>
99
<body>
1010
<div id="root"></div>

website/public/logo.svg

Lines changed: 6 additions & 0 deletions
Loading

0 commit comments

Comments
 (0)