Deploy Notion2Markdown-Action for Hexo Project Using GitHub Actions
In this post, we’ll walk you through the process of deploying the Notion2Markdown-Action for your Hexo project using GitHub Actions. This workflow allows you to synchronize content from Notion to your Hexo blog automatically. We’ll provide a detailed explanation of how to set up the necessary configurations and secrets for this GitHub Actions workflow.
Prerequisites
Before you get started, make sure you have the following prerequisites in place:
Notion Database
For Notion side, you have a prepare a notion dataset and notion integration secret.
For the former, we provide a template here, feel free to duplicate it.
For the notion integration, here is a guide about how to get the integration secret and connect it to the dataset.
DO NOT FORGET TO CONNECT THE DATABASE TO YOUR NOTION INTEGRATION!!!
At this point, NOTION_SECRET
and NOTION_DATABASE_ID
should have been obtained.
A configured image hosting service
If you want to upload all the images hosted by notion, a configured image hosting service shoud be prepared for this action.
Our picture bed service is based on PicGo-Core, so smms/qiniu/upyun/tcyun/github/aliyun/imgur
are supported to be the backend service.
And a JSON configure file should be prepared as PIC_BED_CONFIG
, according to the docs. Here is an example:
|
|
GitHub Actions Workflow
Let’s break down the GitHub Actions workflow step by step.
|
|
Configuration Details
Now, let’s explain each part of the workflow in detail.
- Schedule: The workflow can be triggered manually or on a schedule using the
schedule
option. In this example, it runs every 30 minutes between 7 AM and 10 PM. - Permissions: This workflow requires write permissions to the repository content to update your Hexo blog.
- notionSyncTask: This is the main job of the workflow.
- Checkout blog and theme: It checks out your Hexo blog repository and its submodules.
- Check the NOTION_SYNC_DATETIME: This step retrieves the latest sync datetime from the Git history for tracking changes.
- Convert notion to markdown: This step uses the Notion2Markdown-Action to sync content from Notion to your Hexo blog. It requires several secrets and configurations:
notion_secret
: Your Notion integration secret. HOW TO GET IT?database_id
: The ID of the Notion database you want to sync. HOW TO GET IT?pic_migrate
: Set totrue
to migrate images from Notion to yourpic_bed_config
.pic_bed_config
: Configuration for your image hosting service.pic_compress
: Set totrue
to compress images.output_page_dir
andoutput_post_dir
: Directories where the converted content will be placed in your Hexo project.clean_unpublished_post
: Set totrue
to clean unpublished posts.metas_keeped
andmetas_excluded
: Metadata options.last_sync_datetime
: The datetime of the last sync, retrieved in the previous step.
- Hexo deploy: This step runs when content has been updated. It pulls changes, installs dependencies, and deploys your Hexo blog.
- Commit & Push: Also runs when content has been updated, it commits and pushes the changes to your repository with a specified commit message.
Setting Up Secrets
To use this workflow, you need to set up the following secrets in your GitHub repository, with the location Settings→Secrets and variables→Actions→Secrets→New repository secret
.
NOTION_SECRET
: Your Notion integration secret.NOTION_DATABASE_ID
: The ID of the Notion database you want to sync.PICBED_CONFIG
: Configuration for your image hosting service.
Enjoying!
The workflow is usually triggered according to the schedule, but you can also trigger it manually to see whether it works fine. Tap Actions→Notion2Hexo→Run workflow
to run it.
Conclusion
With this GitHub Actions workflow, you can automate the process of syncing content from Notion to your Hexo blog. Ensure that you have all the prerequisites and secrets set up correctly to make this workflow work seamlessly. Once configured, your Hexo blog will stay up-to-date with your Notion content automatically.