chore: Expand Gemini fallback models and increase sleep to 6.5s to pr… #19
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: Update and Deploy Trending Site | |
| on: | |
| push: | |
| branches: | |
| - main | |
| paths-ignore: | |
| - 'README.md' | |
| - 'LICENSE' | |
| schedule: | |
| # 台灣時間每週六上午 08:00 (UTC 00:00) 執行 | |
| - cron: '0 0 * * 6' | |
| workflow_dispatch: | |
| # 支援在 GitHub 網頁上手動觸發 | |
| permissions: | |
| contents: write # 賦予 GitHub Actions 推送資料與部署 Pages 的權限 | |
| jobs: | |
| update-and-deploy: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: 20 | |
| cache: 'npm' | |
| - name: Install dependencies | |
| run: npm ci || npm install | |
| - name: Fetch and translate trending projects | |
| run: | | |
| if [ -n "${{ secrets.GEMINI_API_KEY }}" ]; then | |
| npm run fetch | |
| else | |
| echo "GEMINI_API_KEY 未設定,跳過資料抓取以防覆蓋翻譯好的資料。" | |
| fi | |
| env: | |
| GEMINI_API_KEY: ${{ secrets.GEMINI_API_KEY }} | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # 內建 Token,用於避免 GitHub Search API 速率限制 | |
| - name: Commit and push changes | |
| run: | | |
| git config --local user.email "action@github.com" | |
| git config --local user.name "github-actions[bot]" | |
| git add src/data/projects*.json || true | |
| # 如果沒有變動,不進行 commit 避免報錯 | |
| git diff-index --quiet HEAD || (git commit -m "chore: update popular projects data (automated) [skip ci]" && git pull --rebase origin main && git push) | |
| - name: Build site | |
| run: npm run build | |
| - name: Deploy to GitHub Pages | |
| uses: peaceiris/actions-gh-pages@v4 | |
| with: | |
| github_token: ${{ secrets.GITHUB_TOKEN }} | |
| publish_dir: ./dist |