Skip to content

Notion2Hexo GP

Notion2Hexo GP #14

Workflow file for this run

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