Skip to content

Deploy Jekyll

Deploy Jekyll #6847

Workflow file for this run

name: Deploy Jekyll
on:
schedule:
- cron: '0 */2 * * *'
workflow_dispatch:
# push:
# branches: ["main"]
permissions:
contents: write
pages: write
id-token: write
concurrency:
group: 'gh-pages'
cancel-in-progress: true
jobs:
build:
runs-on: ubuntu-latest
environment: github-pages
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
TELEGRAM_BOT_API_KEY: ${{ secrets.TELEGRAM_BOT_API_KEY }}
OPENROUTER_API_KEY: ${{ secrets.OPENROUTER_API_KEY }}
steps:
- name: Checkout Repository
uses: actions/checkout@v4
with:
fetch-depth: 5
- name: Set up Python 3.13.2
uses: actions/setup-python@v4
with:
python-version: "3.13.2"
- name: Install Dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements/requirements.txt
- name: Update Language Files
id: updated_lang_files
run: |
DRY_RUN_LANG_OUTPUT=$(python scripts/translation/update_lang.py --commits 1000 --dry_run)
echo "$DRY_RUN_LANG_OUTPUT"
TOTAL_POSTS=$(echo "$DRY_RUN_LANG_OUTPUT" | grep "Total Markdown files to process:" | awk '{print $NF}')
echo "Total posts to process: $TOTAL_POSTS"
if [[ "$TOTAL_POSTS" -eq 0 ]]; then
echo "No language files to update."
else
for i in $(seq 1 "$((2 + TOTAL_POSTS / 9 + (TOTAL_POSTS % 9 != 0)))"); do
python scripts/translation/update_lang.py --max_files 9 --model gemini-flash --commits 1000
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git add _posts/**/*.md
git diff --cached --quiet || git commit -m "chore(lang): Update language files"
git push || {
echo "Push failed, attempting pull and merge"
git pull --rebase
git push
}
done
fi
- name: Translate notes in batches
run: |
python scripts/translation/update_lang_notes.py --n 100 --model gemini-flash
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git add _posts/**/**
git diff --cached --quiet || git commit -m "docs(notes): Add translated notes"
git push || {
echo "Push failed, attempting pull and merge"
git pull --rebase
git push
}
- name: Fix MD Table
run: |
python ./scripts/translation/fix_md_table.py -y
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git add _posts/
git diff --cached --quiet || git commit -m "chore(tables): Fix markdown tables"
git push || {
echo "Push failed, attempting pull and merge"
git pull --rebase
git push
}
- name: Run Unit Tests
run: python -m unittest discover -s tests/workflow
- name: Update Release Hash
run: python scripts/release/update_release.py
- name: Build with Jekyll
uses: actions/jekyll-build-pages@v1
with:
source: ./
destination: ./_site
- name: Check out destination repo
uses: actions/checkout@v4
with:
repository: lzwjava/lzwjava.github.io
token: ${{ secrets.PAT_TOKEN }}
path: destination
fetch-depth: 5
- name: Sync built site to destination repo
run: |
mkdir -p destination/_site
rsync -av --delete _site/ destination/_site/
cd destination
# Optional: ensure Pages doesn’t process Jekyll again
touch _site/.nojekyll
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
if [ -n "$(git status --porcelain)" ]; then
git add -A
git commit -m "update"
git push origin HEAD:main
else
echo "No changes to deploy."
fi
- name: Send Telegram Message
run: |
python scripts/bot/telegram_bot.py --job send_message