diff --git a/.github/workflows/deploy-website.yml b/.github/workflows/deploy-website.yml new file mode 100644 index 0000000..828151a --- /dev/null +++ b/.github/workflows/deploy-website.yml @@ -0,0 +1,65 @@ +name: Deploy Website to GitHub Pages + +on: + push: + branches: + - master # 當推送到 master 分支時觸發 + paths: + - "website/**" # 只有當 website 目錄有變更時才觸發 + workflow_dispatch: # 允許手動觸發 + +# 設定 GITHUB_TOKEN 的權限 +permissions: + contents: read + pages: write + id-token: write + +# 確保同時只有一個部署任務在執行 +concurrency: + group: "pages" + cancel-in-progress: false + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Setup Node.js + uses: actions/setup-node@v4 + with: + node-version: "18" + cache: "npm" + cache-dependency-path: "website/package-lock.json" + + - name: Install dependencies + run: | + cd website + npm i + + - name: Build website + run: | + cd website + npm run build + + - name: Setup Pages + uses: actions/configure-pages@v5 + + - name: Upload artifact + uses: actions/upload-pages-artifact@v3 + with: + path: "./website/dist" + + deploy: + environment: + name: github-pages + url: ${{ steps.deployment.outputs.page_url }} + runs-on: ubuntu-latest + needs: build + + steps: + - name: Deploy to GitHub Pages + id: deployment + uses: actions/deploy-pages@v4 diff --git a/.github/workflows/master.yml b/.github/workflows/master.yml index 2768e1d..306a4c6 100644 --- a/.github/workflows/master.yml +++ b/.github/workflows/master.yml @@ -1,7 +1,8 @@ name: CI - master on: - push: + pull_request: + types: [closed] branches: - "master" @@ -54,6 +55,7 @@ jobs: bump-version: name: Bump Version and Update GitHub Variable runs-on: ubuntu-latest + if: github.event.pull_request.merged == true && contains(github.event.pull_request.labels.*.name, 'build') outputs: new_version: ${{ steps.bump.outputs.new_version }} # needs: unit-test # 等 unit-test 成功才執行 @@ -87,6 +89,7 @@ jobs: build-image: name: Build and Push Docker Image runs-on: ubuntu-latest + if: github.event.pull_request.merged == true && contains(github.event.pull_request.labels.*.name, 'build') needs: # - unit-test # 等 unit-test 成功才執行 - bump-version # 等 bump-version 成功才執行 diff --git a/website/index.html b/website/index.html index e4b78ea..77c380b 100644 --- a/website/index.html +++ b/website/index.html @@ -1,10 +1,10 @@ - +
- + -