Deploy to GitHub Pages #34
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 to GitHub Pages | |
| on: | |
| # mainブランチへのプッシュ時 | |
| push: | |
| branches: [main] | |
| # 日本時間 6:00, 9:00, 12:00, 18:00 に自動ビルド | |
| schedule: | |
| - cron: '0 21 * * *' # JST 6:00 | |
| - cron: '0 0 * * *' # JST 9:00 | |
| - cron: '0 3 * * *' # JST 12:00 | |
| - cron: '0 9 * * *' # JST 18:00 | |
| # 手動実行を許可 | |
| workflow_dispatch: | |
| inputs: | |
| retranslate: | |
| description: '「(翻訳待ち)」エントリを再翻訳' | |
| type: boolean | |
| default: false | |
| # ページデプロイの権限設定 | |
| permissions: | |
| contents: write # sync-versions での自動コミットに必要 | |
| pages: write | |
| id-token: write | |
| # 同時デプロイを防止 | |
| concurrency: | |
| group: pages | |
| cancel-in-progress: false | |
| jobs: | |
| build: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Setup pnpm | |
| uses: pnpm/action-setup@v4 | |
| with: | |
| version: 10 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: 22 | |
| cache: pnpm | |
| - name: Install dependencies | |
| run: pnpm install | |
| - name: Install Claude Code CLI | |
| run: npm install -g @anthropic-ai/claude-code | |
| - name: Sync new versions from npm | |
| env: | |
| CLAUDE_CODE_OAUTH_TOKEN: ${{ secrets.CLAUDE_CODE_OAUTH_TOKEN }} | |
| run: pnpm run sync-versions | |
| - name: Retranslate pending entries | |
| if: ${{ github.event.inputs.retranslate == 'true' }} | |
| env: | |
| CLAUDE_CODE_OAUTH_TOKEN: ${{ secrets.CLAUDE_CODE_OAUTH_TOKEN }} | |
| run: pnpm run retranslate | |
| - name: Commit new versions (if any) | |
| run: | | |
| git config user.name "github-actions[bot]" | |
| git config user.email "github-actions[bot]@users.noreply.github.com" | |
| git add content/CHANGELOG_*.md | |
| git diff --staged --quiet || git commit -m "chore: 新バージョンを自動追加" | |
| git push || echo "Nothing to push" | |
| - name: Build | |
| run: pnpm build | |
| - name: Upload artifact | |
| uses: actions/upload-pages-artifact@v3 | |
| with: | |
| path: ./dist | |
| deploy: | |
| environment: | |
| name: github-pages | |
| url: ${{ steps.deployment.outputs.page_url }} | |
| needs: build | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Deploy to GitHub Pages | |
| id: deployment | |
| uses: actions/deploy-pages@v4 |