-
Notifications
You must be signed in to change notification settings - Fork 0
105 lines (87 loc) · 2.57 KB
/
sync.yml
File metadata and controls
105 lines (87 loc) · 2.57 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
name: Sync Telegraph Posts and Deploy
on:
schedule:
# Запускаем каждый день в 6:00 UTC (9:00 MSK)
- cron: '0 6 * * *'
workflow_dispatch: # Позволяет запускать вручную
push:
branches: [ main ]
paths:
- '_posts/**'
- '_config.yml'
- 'index.html'
- '_layouts/**'
- 'assets/**'
jobs:
sync-and-deploy:
runs-on: ubuntu-latest
permissions:
contents: write
pages: write
id-token: write
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: '3.11'
cache: 'pip'
- name: Install Python dependencies
run: |
pip install -r requirements.txt
- name: Setup Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: '3.1'
bundler-cache: true
- name: Install Jekyll dependencies
run: |
bundle install
- name: Sync Telegraph posts
env:
TELEGRAM_API_ID: ${{ secrets.TELEGRAM_API_ID }}
TELEGRAM_API_HASH: ${{ secrets.TELEGRAM_API_HASH }}
run: |
cd scripts
python sync_telegraph.py
- name: Check for changes
id: changes
run: |
git config --local user.email "action@github.com"
git config --local user.name "GitHub Action"
# Проверяем, есть ли изменения
if [[ -n $(git status --porcelain) ]]; then
echo "changes=true" >> $GITHUB_OUTPUT
# Коммитим изменения
git add .
git commit -m "Auto-sync: Update Telegraph posts $(date '+%Y-%m-%d %H:%M')"
git push
else
echo "changes=false" >> $GITHUB_OUTPUT
echo "No changes detected"
fi
- name: Build Jekyll site
run: |
bundle exec jekyll build --destination ./_site
env:
JEKYLL_ENV: production
- name: Setup Pages
uses: actions/configure-pages@v3
- name: Upload artifact
uses: actions/upload-pages-artifact@v2
with:
path: ./_site
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v2
- name: Notify on success
if: steps.changes.outputs.changes == 'true'
run: |
echo "✅ Successfully synced and deployed new posts"
- name: Notify on failure
if: failure()
run: |
echo "❌ Sync or deployment failed"