You can automate the export of your Notion pages to a static site hosted on GitHub Pages.
1. Set up Repository Secrets
In your target GitHub repository, navigate to Settings -> Secrets -> Actions -> New repository secret and add:
NOTION_PAGE_ID: Your Notion page ID.NOTION_TOKEN: Your Notion Internal Integration Token.
2. Configure the Workflow
Create a .github/workflows/publish.yml file in your repository. The workflow performs the following steps:
- Installs Google Chrome (required for certain rendering tasks).
- Sets up Python 3.10.
- Checks out the
notion4ever repository. - Installs dependencies via
pip install -r requirements.txt. - Checks out your static site repository to a specific path (e.g.,
_site). - Runs
python -m notion4ever using environment variables for configuration. - Deploys the generated content to your
main branch using JamesIves/github-pages-deploy-action.
Note: You must set the SITE_URL environment variable in the workflow to your actual website URL (e.g., https://<username>.github.io).
name: Deploy from Notion to Pages
on:
schedule:
- cron: "0 */12 * * *"
jobs:
download_old-generate-push:
runs-on: ubuntu-latest
steps:
- name: Submodule Update
run: |
wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb
sudo apt install ./google-chrome-stable_current_amd64.deb
sudo apt-get update
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: 3.10.0
- name: Download notion4ever
uses: actions/checkout@v2
with:
repository: 'MerkulovDaniil/notion4ever'
- name: Install packages
run: pip install -r requirements.txt
- name: Download current version of the site
uses: actions/checkout@v2
with:
repository: 'YOUR_REPOSITORY_HERE'
ref: main
path: _site
- name: Run notion4ever
run: python -m notion4ever
env:
SITE_URL: "https://your-site-url.com"
NOTION_TOKEN: ${{secrets.NOTION_TOKEN}}
NOTION_PAGE_ID: ${{secrets.NOTION_PAGE_ID}}
- name: Deploy to Pages
uses: JamesIves/github-pages-deploy-action@3.7.1
with:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
BRANCH: main
FOLDER: _site
COMMIT_MESSAGE: 🤖 Deployed via notion4ever.