Skip to content

commit

commit #405

Workflow file for this run

name: Deploy VitePress site
on:
push:
branches: [main]
workflow_dispatch:
permissions:
contents: write
pages: write
id-token: write
concurrency:
group: pages
cancel-in-progress: false
jobs:
build:
runs-on: ubuntu-latest
# Экспортируем время старта, чтобы job 'deploy' мог его увидеть
outputs:
start_time: ${{ steps.timer.outputs.start_time }}
formatted_start: ${{ steps.timer.outputs.formatted_start }}
steps:
# --- [NEW] 1. Засекаем время ---
- name: Start Timer
id: timer
run: |
# Сохраняем текущую секунду (epoch) для математики
echo "start_time=$(date +%s)" >> $GITHUB_OUTPUT
# Сохраняем красивое время для сообщений (Москва +3 часа)
# Если нужно UTC, уберите 'TZ=Europe/Moscow'
echo "formatted_start=$(TZ=Europe/Moscow date '+%H:%M:%S')" >> $GITHUB_OUTPUT
# --- [NEW] 2. Уведомление о старте ---
- name: Telegram - Start
uses: appleboy/telegram-action@master
with:
to: ${{ secrets.TELEGRAM_TO }}
token: ${{ secrets.TELEGRAM_TOKEN }}
message: |
🚀 Началась сборка документации!
⏰ Время старта: ${{ steps.timer.outputs.formatted_start }}
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup pnpm
uses: pnpm/action-setup@v3
with:
version: 9
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: 20
cache: pnpm
- name: Install dependencies
run: pnpm install --no-frozen-lockfile
- name: Build with VitePress
run: pnpm docs:build
# --- БЛОК 1: Обновляем файлы в ТЕКУЩЕМ репозитории ---
- name: Commit and Push to CURRENT repo
run: |
git config --global user.name "github-actions[bot]"
git config --global user.email "github-actions[bot]@users.noreply.github.com"
git add llms.txt llms-full.txt
if [[ -n $(git status -s) ]]; then
git commit -m "chore: update llms docs [skip ci]"
git push
else
echo "No changes"
fi
# --- БЛОК 2: Отправляем файлы в ДРУГОЙ репозиторий ---
- name: Manual Push to TGZ repo
env:
TOKEN: ${{ secrets.API_TOKEN_GITHUB }}
run: |
git clone --depth 1 https://oauth2:$TOKEN@github.com/ZenithGram/php-telegram-bot-library.git temp_ai
cd temp_ai
mkdir -p ai-context
cp ../llms.txt ai-context/
cp ../llms-full.txt ai-context/
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git add ai-context/
if git diff --staged --quiet; then
echo "Нет изменений для записи"
else
git commit -m "Обновление после изменений в документации"
git push
echo "✅ Успешно отправлено в ZenithGram/ai-context"
fi
- name: Setup Pages
uses: actions/configure-pages@v4
- name: Upload artifact
uses: actions/upload-pages-artifact@v3
with:
path: docs/.vitepress/dist
- name: Telegram - Build Failure
if: failure()
uses: appleboy/telegram-action@master
with:
to: ${{ secrets.TELEGRAM_TO }}
token: ${{ secrets.TELEGRAM_TOKEN }}
message: |
❌ Ошибка на этапе сборки (Build)!
Логи: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}
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
# --- [NEW] 3. Считаем и отправляем итог ---
- name: Telegram - Success
if: success()
id: stats
env:
# Забираем время старта из предыдущего job (build)
START_TIME: ${{ needs.build.outputs.start_time }}
run: |
NOW=$(date +%s)
DURATION=$((NOW - START_TIME))
# Форматируем секунды в минуты:секунды
echo "formatted_duration=$((DURATION / 60))м $((DURATION % 60))с" >> $GITHUB_OUTPUT
echo "formatted_end=$(TZ=Europe/Moscow date '+%H:%M:%S')" >> $GITHUB_OUTPUT
- name: Send Final Notification
if: success()
uses: appleboy/telegram-action@master
with:
to: ${{ secrets.TELEGRAM_TO }}
token: ${{ secrets.TELEGRAM_TOKEN }}
message: |
✅ Документация обновлена!
🏁 Финиш: ${{ steps.stats.outputs.formatted_end }}
⏱ Время: ${{ steps.stats.outputs.formatted_duration }}
- name: Telegram - Deploy Failure
if: failure()
uses: appleboy/telegram-action@master
with:
to: ${{ secrets.TELEGRAM_TO }}
token: ${{ secrets.TELEGRAM_TOKEN }}
message: |
❌ Ошибка на этапе деплоя!
⏰ Старт был в: ${{ needs.build.outputs.formatted_start }}
Логи: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}