Repository navigation
Translate Digest (Vietnamese) #205
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: Translate Digest (Vietnamese) | |
| on: | |
| schedule: | |
| # 01:00 UTC = 09:00 CST — 1 hour after upstream daily digest completes | |
| - cron: "0 1 * * *" | |
| workflow_dispatch: | |
| inputs: | |
| date: | |
| description: "Date to translate (YYYY-MM-DD). Leave empty for today." | |
| required: false | |
| permissions: | |
| contents: write | |
| jobs: | |
| translate: | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 15 | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Sync digests from upstream (duanyytop/agents-radar) | |
| run: | | |
| git config user.name "github-actions[bot]" | |
| git config user.email "github-actions[bot]@users.noreply.github.com" | |
| git remote add upstream https://github.com/duanyytop/agents-radar.git || true | |
| git fetch upstream master | |
| # Only copy digests/ from upstream — avoids workflow permission issues | |
| git checkout upstream/master -- digests/ || true | |
| git add digests/ | |
| if ! git diff --cached --quiet; then | |
| git commit -m "sync: update digests from upstream" | |
| git push | |
| else | |
| echo "Digests already up to date." | |
| fi | |
| - name: Determine target date | |
| id: date | |
| run: | | |
| if [ -n "${{ github.event.inputs.date }}" ]; then | |
| echo "target=${{ github.event.inputs.date }}" >> "$GITHUB_OUTPUT" | |
| else | |
| echo "target=$(date -u +%Y-%m-%d)" >> "$GITHUB_OUTPUT" | |
| fi | |
| - name: Check if source files exist | |
| id: check | |
| run: | | |
| DIR="digests/${{ steps.date.outputs.target }}" | |
| if [ -d "$DIR" ] && ls "$DIR"/ai-*.md 1>/dev/null 2>&1; then | |
| echo "has_source=true" >> "$GITHUB_OUTPUT" | |
| else | |
| echo "has_source=false" >> "$GITHUB_OUTPUT" | |
| echo "No source files found in $DIR — skipping translation." | |
| fi | |
| - name: Setup pnpm | |
| if: steps.check.outputs.has_source == 'true' | |
| uses: pnpm/action-setup@v4 | |
| - name: Setup Node.js | |
| if: steps.check.outputs.has_source == 'true' | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: 22 | |
| cache: pnpm | |
| - name: Install dependencies | |
| if: steps.check.outputs.has_source == 'true' | |
| run: pnpm install --frozen-lockfile | |
| - name: Debug env vars | |
| if: steps.check.outputs.has_source == 'true' | |
| env: | |
| OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }} | |
| OPENAI_BASE_URL: ${{ secrets.OPENAI_BASE_URL }} | |
| OPENAI_MODEL: ${{ vars.OPENAI_MODEL }} | |
| run: | | |
| echo "OPENAI_API_KEY set: $([ -n "$OPENAI_API_KEY" ] && echo 'yes ('${#OPENAI_API_KEY}' chars)' || echo 'NO')" | |
| echo "OPENAI_BASE_URL set: $([ -n "$OPENAI_BASE_URL" ] && echo 'yes' || echo 'NO')" | |
| echo "OPENAI_BASE_URL value: $OPENAI_BASE_URL" | |
| echo "OPENAI_MODEL: ${OPENAI_MODEL:-'(not set, default gpt-4o)'}" | |
| - name: Translate to Vietnamese | |
| if: steps.check.outputs.has_source == 'true' | |
| env: | |
| OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }} | |
| OPENAI_BASE_URL: ${{ secrets.OPENAI_BASE_URL }} | |
| OPENAI_MODEL: ${{ vars.OPENAI_MODEL }} | |
| run: npx tsx src/translate.ts ${{ steps.date.outputs.target }} | |
| - name: Commit translated files | |
| if: steps.check.outputs.has_source == 'true' | |
| run: | | |
| git add digests/ | |
| if git diff --cached --quiet; then | |
| echo "No new translated files to commit" | |
| else | |
| DATE="${{ steps.date.outputs.target }}" | |
| git commit -m "translate: ${DATE} Vietnamese digest" | |
| git pull --rebase | |
| git push | |
| fi | |
| - name: Send Telegram notification | |
| if: steps.check.outputs.has_source == 'true' | |
| env: | |
| TELEGRAM_BOT_TOKEN: ${{ secrets.TELEGRAM_BOT_TOKEN }} | |
| TELEGRAM_CHAT_ID: ${{ secrets.TELEGRAM_CHAT_ID }} | |
| PAGES_URL: ${{ vars.PAGES_URL }} | |
| run: npx tsx src/notify-vi.ts ${{ steps.date.outputs.target }} |