Commit Notion changes #50
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Commit Notion changes | |
on: | |
workflow_dispatch: | |
inputs: | |
commit_message: | |
type: string | |
description: Commit message to use for this content build step | |
required: false | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.ref }} | |
cancel-in-progress: true | |
jobs: | |
commit: | |
runs-on: ubuntu-latest | |
env: | |
TZ: 'America/Los_Angeles' | |
permissions: | |
contents: write | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set up Node.js | |
uses: actions/setup-node@v4 | |
with: | |
node-version: 18 | |
- name: Run install | |
uses: borales/actions-yarn@v5 | |
with: | |
cmd: install | |
- name: Run Notion script | |
uses: borales/actions-yarn@v5 | |
env: | |
NOTION_SECRET: ${{ secrets.NOTION_SECRET }} | |
NOTION_DATABASE_ID: ${{ secrets.NOTION_DATABASE_ID }} | |
CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }} | |
CLOUDFLARE_R2_ACCESS_KEY_ID: ${{ secrets.CLOUDFLARE_R2_ACCESS_KEY_ID }} | |
CLOUDFLARE_R2_SECRET_ACCESS_KEY: ${{ secrets.CLOUDFLARE_R2_SECRET_ACCESS_KEY }} | |
R2_BUCKET_NAME: ${{ secrets.R2_BUCKET_NAME }} | |
with: | |
cmd: notion-to-md | |
continue-on-error: true | |
- name: Check for script errors | |
run: | | |
if [ $? -ne 0 ]; then | |
echo "Notion script failed. Check the logs for errors." | |
exit 1 | |
fi | |
- name: Fix Formatting | |
uses: borales/actions-yarn@v5 | |
with: | |
cmd: format:write | |
- name: Stage all changes | |
run: | | |
git add . | |
git diff --staged --quiet || echo "CHANGES_EXIST=true" >> $GITHUB_ENV | |
- name: Commit Changes | |
if: env.CHANGES_EXIST == 'true' | |
uses: planetscale/ghcommit-action@v0.1.33 | |
with: | |
commit_message: ${{ github.event.inputs.commit_message || 'Update from Notion' }} | |
repo: ${{ github.repository }} | |
branch: ${{ github.head_ref || github.ref_name }} | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- name: Check for commit errors | |
if: env.CHANGES_EXIST == 'true' | |
run: | | |
if [ $? -ne 0 ]; then | |
echo "Failed to commit changes. Check the logs for errors." | |
exit 1 | |
fi |