-
Notifications
You must be signed in to change notification settings - Fork 0
90 lines (83 loc) · 2.69 KB
/
Notion2Hexo.yml
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
name: Notion2Hexo GP
on:
workflow_dispatch:
repository_dispatch:
types:
- notion_sync
concurrency:
group: notion-sync-${{ github.ref }}
permissions:
contents: write
pages: write
id-token: write
jobs:
notionSyncTask:
name: Notion2Hexo on ${{ matrix.os }}
runs-on: ubuntu-latest
timeout-minutes: 20
strategy:
matrix:
os: [ubuntu-latest]
node_version: [14.x]
outputs:
HAS_CHANGES: ${{ steps.NotionSync.outputs.updated_count != '0' }}
steps:
- name: Checkout blog and theme
uses: actions/checkout@v3
with:
submodules: 'recursive'
fetch-depth: 0
- name: Check the NOTION_SYNC_DATETIME
id: GetNotionSyncDatetime
run: |
echo -e "Latest commit id: $(git rev-parse HEAD)"
echo -e "Latest notion sync commit:\n$(git log -n 1 --grep="NotionSync")"
NOTION_SYNC_DATETIME=$(git log -n 1 --grep="NotionSync" --format="%aI")
echo "NOTION_SYNC_DATETIME: $NOTION_SYNC_DATETIME"
echo "NOTION_SYNC_DATETIME=$NOTION_SYNC_DATETIME" >> "$GITHUB_OUTPUT"
- name: Convert notion to markdown
id: NotionSync
uses: Doradx/notion2markdown-action@v1
with:
notion_secret: ${{ secrets.NOTION_TOKEN }}
database_id: ${{ secrets.NOTION_DATABASE_ID }}
pic_migrate: true
pic_bed_config: ${{ secrets.PICBED_CONFIG }}
pic_compress: true
output_page_dir: 'source'
output_post_dir: 'source/_posts/notion'
clean_unpublished_post: true
last_sync_datetime: ${{ steps.GetNotionSyncDatetime.outputs.NOTION_SYNC_DATETIME }}
timezone: 'Asia/Shanghai'
- name: Sync git
if: steps.NotionSync.outputs.updated_count != '0'
run: |
git pull
- name: Commit & Push
if: steps.NotionSync.outputs.updated_count != '0'
uses: stefanzweifel/git-auto-commit-action@v4
with:
file_pattern: 'source/'
commit_message: Automatic NotionSync.
- name: Setup Node.js
uses: actions/setup-node@v1
with:
node-version: '12'
- name: Setup Hexo
env:
ACTION_DEPLOY_KEY: ${{ secrets.HEXO_DEPLOY_KEY }}
run: |
mkdir -p ~/.ssh/
echo "$ACTION_DEPLOY_KEY" > ~/.ssh/id_rsa
chmod 700 ~/.ssh
chmod 600 ~/.ssh/id_rsa
ssh-keyscan github.com >> ~/.ssh/known_hosts
git config --global user.email "[email protected]"
git config --global user.name "John Doe"
npm install hexo-cli -g
npm install
- name: Deploy
run: |
hexo clean
hexo g
hexo deploy