Add multiple website deployment workflows #1
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Deploy Both Websites to GitHub Pages | |
| on: | |
| push: | |
| branches: [ main, master ] | |
| paths: | |
| - 'ex01/web/**' | |
| - 'ex02/mockup/**' | |
| workflow_dispatch: | |
| permissions: | |
| contents: read | |
| pages: write | |
| id-token: write | |
| concurrency: | |
| group: "pages-both" | |
| cancel-in-progress: false | |
| jobs: | |
| deploy: | |
| environment: | |
| name: github-pages | |
| url: ${{ steps.deployment.outputs.page_url }} | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Setup Pages | |
| uses: actions/configure-pages@v4 | |
| - name: Create combined website structure | |
| run: | | |
| # 建立根目錄的 index.html 作為導航頁面 | |
| mkdir -p public | |
| echo '<!DOCTYPE html> | |
| <html lang="zh-TW"> | |
| <head> | |
| <meta charset="UTF-8"> | |
| <meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
| <title>學習專案網站</title> | |
| <style> | |
| body { font-family: Arial, sans-serif; max-width: 800px; margin: 0 auto; padding: 20px; } | |
| .website-link { display: block; margin: 20px 0; padding: 20px; background: #f5f5f5; border-radius: 8px; text-decoration: none; color: #333; } | |
| .website-link:hover { background: #e0e0e0; } | |
| h1 { color: #2c3e50; } | |
| h2 { color: #34495e; } | |
| </style> | |
| </head> | |
| <body> | |
| <h1>🎓 學習專案網站</h1> | |
| <p>歡迎來到我的學習專案展示網站!</p> | |
| <a href="./ex01-web/" class="website-link"> | |
| <h2>📚 EX01 - 網站專案</h2> | |
| <p>點擊進入 EX01 網站專案</p> | |
| </a> | |
| <a href="./ex02-mockup/" class="website-link"> | |
| <h2>🍽️ EX02 - 餐廳點餐系統</h2> | |
| <p>點擊進入餐廳點餐系統 Mockup</p> | |
| </a> | |
| </body> | |
| </html>' > public/index.html | |
| # 複製 ex01/web 到 ex01-web 子目錄 | |
| mkdir -p public/ex01-web | |
| cp -r ex01/web/* public/ex01-web/ | |
| # 複製 ex02/mockup 到 ex02-mockup 子目錄 | |
| mkdir -p public/ex02-mockup | |
| cp -r ex02/mockup/* public/ex02-mockup/ | |
| - name: Upload artifact | |
| uses: actions/upload-pages-artifact@v3 | |
| with: | |
| path: './public' | |
| - name: Deploy to GitHub Pages | |
| id: deployment | |
| uses: actions/deploy-pages@v4 |