Daily Content Generation #55
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: Daily Content Generation | |
| on: | |
| schedule: | |
| - cron: '30 15 * * 1,3,5' # 월/수/금 00:30 KST (UTC 15:30) | |
| workflow_dispatch: | |
| inputs: | |
| language: | |
| description: '언어 코드' | |
| required: true | |
| default: 'en' | |
| type: choice | |
| options: | |
| - en | |
| - ja | |
| difficulty: | |
| description: '난이도' | |
| required: true | |
| default: '초급' | |
| type: choice | |
| options: | |
| - 초급 | |
| - 중급 | |
| - 고급 | |
| jobs: | |
| generate-content: | |
| runs-on: ubuntu-latest | |
| env: | |
| GEMINI_CLI_TRUST_WORKSPACE: 'true' | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| with: | |
| token: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: 22.17.1 | |
| - name: Setup pnpm | |
| uses: pnpm/action-setup@v4 | |
| with: | |
| version: 9.0.0 | |
| - name: Install dependencies | |
| run: pnpm install | |
| - name: Install gemini-cli | |
| run: | | |
| npm install -g @google/gemini-cli | |
| echo "$(npm root -g)/../bin" >> $GITHUB_PATH | |
| - name: Generate content | |
| id: generate | |
| env: | |
| GEMINI_API_KEY: ${{ secrets.GEMINI_API_KEY }} | |
| PUBLIC_SUPABASE_URL: ${{ secrets.PUBLIC_SUPABASE_URL }} | |
| PUBLIC_SUPABASE_ANON_KEY: ${{ secrets.PUBLIC_SUPABASE_ANON_KEY }} | |
| run: | | |
| LANGUAGE="${{ github.event.inputs.language || 'en' }}" | |
| DIFFICULTY="${{ github.event.inputs.difficulty || '초급' }}" | |
| echo "언어: $LANGUAGE" | |
| echo "난이도: $DIFFICULTY" | |
| chmod +x .github/scripts/generate-daily-content.sh | |
| ./.github/scripts/generate-daily-content.sh "$LANGUAGE" "$DIFFICULTY" | |
| - name: Commit and push changes | |
| env: | |
| LANGUAGE: ${{ github.event.inputs.language || 'en' }} | |
| DIFFICULTY: ${{ github.event.inputs.difficulty || '초급' }} | |
| run: | | |
| git config --local user.email "github-actions[bot]@users.noreply.github.com" | |
| git config --local user.name "github-actions[bot]" | |
| if [ -n "$(git status --porcelain)" ]; then | |
| NEW_FILE=$(git status --porcelain | grep "content/source/.*\.md" | awk '{print $2}' | head -1) | |
| if [ -n "$NEW_FILE" ]; then | |
| TITLE=$(grep -m 1 "^title:" "$NEW_FILE" | sed 's/title: //' | tr -d '"') | |
| else | |
| TITLE="새 학습 콘텐츠" | |
| fi | |
| if [ -z "$TITLE" ]; then | |
| TITLE="새 학습 콘텐츠" | |
| fi | |
| git add content/source/ content/.content-index.json content/json/ | |
| git commit -m "content: ${TITLE} (${LANGUAGE} ${DIFFICULTY})" | |
| if [ -z "$ACT" ]; then | |
| git push | |
| echo "✅ 커밋 및 푸시 완료: content: ${TITLE} (${LANGUAGE} ${DIFFICULTY})" | |
| else | |
| echo "✅ 커밋 완료 (act 환경이므로 push 스킵): content: ${TITLE} (${LANGUAGE} ${DIFFICULTY})" | |
| fi | |
| else | |
| echo "⚠️ 변경사항이 없습니다." | |
| fi | |
| - name: Summary | |
| if: always() | |
| run: | | |
| echo "## 콘텐츠 생성 완료 🎉" >> $GITHUB_STEP_SUMMARY | |
| echo "" >> $GITHUB_STEP_SUMMARY | |
| echo "- **언어**: ${{ github.event.inputs.language || 'en' }}" >> $GITHUB_STEP_SUMMARY | |
| echo "- **난이도**: ${{ github.event.inputs.difficulty || '초급' }}" >> $GITHUB_STEP_SUMMARY | |
| echo "- **생성 시각**: $(date +'%Y-%m-%d %H:%M:%S')" >> $GITHUB_STEP_SUMMARY | |
| echo "" >> $GITHUB_STEP_SUMMARY | |
| REMAINING=$(jq '[.weekly_plan.planned_slugs[] | select(.used == false)] | length' content/.content-index.json) | |
| echo "- **남은 주간 계획**: ${REMAINING}/3" >> $GITHUB_STEP_SUMMARY |