-
Notifications
You must be signed in to change notification settings - Fork 1
86 lines (74 loc) · 2.6 KB
/
notion.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
name: Fetch and commit Notion changes
on:
workflow_dispatch:
inputs:
commit_message:
type: string
description: Commit message to use for this content build step
required: false
repository_dispatch:
types:
- 'chore: fetch and commit Notion changes'
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
commit:
runs-on: ubuntu-latest
env:
TZ: 'America/Los_Angeles'
DEFAULT_COMMIT_MESSAGE: 'chore: update from Notion'
permissions:
contents: write
steps:
- uses: actions/checkout@v4
- name: Enable Corepack
run: corepack enable
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: 18
cache: 'yarn'
cache-dependency-path: 'yarn.lock'
- name: Install dependencies
run: yarn install --frozen-lockfile
- name: Run Notion script
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 }}
CLOUDFLARE_R2_ENDPOINT: ${{ secrets.CLOUDFLARE_R2_ENDPOINT }}
R2_BUCKET_NAME: ${{ secrets.R2_BUCKET_NAME }}
run: yarn notion
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
run: yarn format:write
- name: Stage all changes
id: stage
run: |
git add .
git diff --staged --quiet || echo "CHANGES_EXIST=true" >> $GITHUB_OUTPUT
- name: Commit Changes
if: ${{ steps.stage.outputs.CHANGES_EXIST == 'true' }}
uses: planetscale/[email protected]
with:
commit_message: ${{ github.event.client_payload.commit_message || github.event.inputs.commit_message || env.DEFAULT_COMMIT_MESSAGE }}
repo: ${{ github.repository }}
branch: ${{ github.head_ref || github.ref_name }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Check for commit errors
if: ${{ steps.stage.outputs.CHANGES_EXIST == 'true' }}
run: |
if [ $? -ne 0 ]; then
echo "Failed to commit changes. Check the logs for errors."
exit 1
fi