Skip to content

Commit

Permalink
Merge pull request #46 from cognano/rotion-upgrade
Browse files Browse the repository at this point in the history
Replace to Rotion from Notionate and Some styles fixes
  • Loading branch information
linyows authored May 29, 2024
2 parents 5793d1a + ea5edf4 commit d3591bc
Show file tree
Hide file tree
Showing 37 changed files with 2,822 additions and 2,753 deletions.
73 changes: 6 additions & 67 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Build and Deploy to staging
name: Build

on:
repository_dispatch:
Expand All @@ -12,16 +12,16 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [18.x]
node-version: [22.x]
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
cache: yarn
- name: Restore next cache
uses: actions/cache@v3
uses: actions/cache@v4
with:
path: |
.next/cache
Expand All @@ -31,66 +31,5 @@ jobs:
- name: Run builds and deploys with ${{ matrix.node-version }}
run: |
yarn install
yarn add sharp --ignore-engines
yarn lint
staging:
runs-on: ubuntu-latest
needs: [build]
env:
NOTION_TOKEN: ${{ secrets.NOTION_TOKEN }}
NOTIONATE_INCREMENTAL_CACHE: true
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 18
cache: yarn
- name: Restore next cache
uses: actions/cache@v3
with:
path: |
.next/cache
key: nextjs-${{ hashFiles('**/package-lock.json', '**/yarn.lock') }}-${{ hashFiles('**.[jt]s', '**.[jt]sx') }}
restore-keys: |
nextjs-${{ hashFiles('**/package-lock.json', '**/yarn.lock') }}-
- name: Restore notionate cache
uses: actions/cache@v3
with:
path: |
.cache
public/images
key: notionate-stag
restore-keys: notionate-stag
- name: Install packages
run: |
yarn install
- name: Run next export
run: |
yarn build
env:
NEXT_PUBLIC_LANG: en
BUILD_ENV: staging
- name: Deploy to staging by FTP
uses: SamKirkland/[email protected]
with:
server: ${{ secrets.FTPHOST }}
username: ${{ secrets.FTPUSERNAME_STAG_EN }}
password: ${{ secrets.FTPPASSWORD_STAG_EN }}
local-dir: ./out/
exclude: |
ogimages/*-ja-*.png
- name: Run next export for japanese
run: |
yarn build
env:
NEXT_PUBLIC_LANG: ja
BUILD_ENV: staging
- name: Deploy to staging by FTP
uses: SamKirkland/[email protected]
with:
server: ${{ secrets.FTPHOST }}
username: ${{ secrets.FTPUSERNAME_STAG }}
password: ${{ secrets.FTPPASSWORD_STAG }}
local-dir: ./out/
exclude: |
ogimages/*-en-*.png
77 changes: 27 additions & 50 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,93 +2,70 @@ name: Release

on:
repository_dispatch:
push:
branches:
- main
workflow_dispatch:
workflow_run:
workflows: ["Build"]
branches: [main]
types: [completed]

jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [18.x]
steps:
- uses: actions/checkout@v3
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
cache: yarn
- name: Restore next cache
uses: actions/cache@v3
with:
path: |
.next/cache
key: nextjs-${{ hashFiles('**/package-lock.json', '**/yarn.lock') }}-${{ hashFiles('**.[jt]s', '**.[jt]sx') }}
restore-keys: |
nextjs-${{ hashFiles('**/package-lock.json', '**/yarn.lock') }}-
- name: Run builds and deploys with ${{ matrix.node-version }}
run: |
yarn install
yarn lint
release:
runs-on: ubuntu-latest
needs: [build]
env:
NOTION_TOKEN: ${{ secrets.NOTION_TOKEN }}
NOTIONATE_INCREMENTAL_CACHE: true
ROTION_INCREMENTAL_CACHE: true
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 18
node-version: 22
cache: yarn
- name: Restore next cache
uses: actions/cache@v3
uses: actions/cache@v4
with:
path: |
.next/cache
key: nextjs-${{ hashFiles('**/package-lock.json', '**/yarn.lock') }}-${{ hashFiles('**.[jt]s', '**.[jt]sx') }}
restore-keys: |
nextjs-${{ hashFiles('**/package-lock.json', '**/yarn.lock') }}-
- name: Restore notionate cache
uses: actions/cache@v3
- name: Restore rotion cache
uses: actions/cache@v4
with:
path: |
.cache
public/images
public/ogimages
key: notionate
restore-keys: notionate
key: rotion-prod
restore-keys: rotion-prod
- name: Install packages
run: |
yarn install
- name: Run next export for english
yarn add sharp --ignore-engines
- name: Run next build for english
run: |
yarn build
env:
NEXT_PUBLIC_LANG: en
- name: Deploy to production by FTP
uses: SamKirkland/FTP-Deploy-Action@4.3.0
- name: Deploy to prod.cognanous.com by FTP
uses: SamKirkland/FTP-Deploy-Action@v4.3.5
with:
server: ${{ secrets.FTPHOST }}
username: ${{ secrets.FTPUSERNAME_PROD_EN }}
password: ${{ secrets.FTPPASSWORD_PROD_EN }}
server: ${{ secrets.FTP_HOST }}
username: ${{ secrets.FTP_USER_PROD_EN }}
password: ${{ secrets.FTP_PASS_PROD_EN }}
local-dir: ./out/
exclude: |
ogimages/*-ja-*.png
- name: Run next export for japanese
- name: Run next build for japanese
run: |
yarn build
env:
NEXT_PUBLIC_LANG: ja
- name: Deploy to production by FTP
uses: SamKirkland/FTP-Deploy-Action@4.3.0
- name: Deploy to prod.cognano.co.jp by FTP
uses: SamKirkland/FTP-Deploy-Action@v4.3.5
with:
server: ${{ secrets.FTPHOST }}
username: ${{ secrets.FTPUSERNAME_PROD }}
password: ${{ secrets.FTPPASSWORD_PROD }}
server: ${{ secrets.FTP_HOST }}
username: ${{ secrets.FTP_USER_PROD_JA }}
password: ${{ secrets.FTP_PASS_PROD_JA }}
local-dir: ./out/
exclude: |
ogimages/*-en-*.png
72 changes: 72 additions & 0 deletions .github/workflows/staging.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
name: Staging

on:
repository_dispatch:
workflow_dispatch:
workflow_run:
workflows: ["Build"]
types: [completed]

jobs:
staging:
runs-on: ubuntu-latest
env:
NOTION_TOKEN: ${{ secrets.NOTION_TOKEN }}
ROTION_INCREMENTAL_CACHE: true
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 22
cache: yarn
- name: Restore next cache
uses: actions/cache@v4
with:
path: |
.next/cache
key: nextjs-${{ hashFiles('**/package-lock.json', '**/yarn.lock') }}-${{ hashFiles('**.[jt]s', '**.[jt]sx') }}
restore-keys: |
nextjs-${{ hashFiles('**/package-lock.json', '**/yarn.lock') }}-
- name: Restore rotion cache
uses: actions/cache@v4
with:
path: |
.cache
public/images
public/ogimages
key: rotion-stag
restore-keys: rotion-stag
- name: Install packages
run: |
yarn install
yarn add sharp --ignore-engines
- name: Run next build for english
run: |
yarn build
env:
NEXT_PUBLIC_LANG: en
BUILD_ENV: staging
- name: Deploy to stag.cognanous.com by FTP
uses: SamKirkland/[email protected]
with:
server: ${{ secrets.FTP_HOST }}
username: ${{ secrets.FTP_USER_STAG_EN }}
password: ${{ secrets.FTP_PASS_STAG_EN }}
local-dir: ./out/
exclude: |
ogimages/*-ja-*.png
- name: Run next build for japanese
run: |
yarn build
env:
NEXT_PUBLIC_LANG: ja
BUILD_ENV: staging
- name: Deploy to stag.cognano.co.jp by FTP
uses: SamKirkland/[email protected]
with:
server: ${{ secrets.FTPHOST }}
username: ${{ secrets.FTP_USER_STAG_JA }}
password: ${{ secrets.FTP_PASS_STAG_JA }}
local-dir: ./out/
exclude: |
ogimages/*-en-*.png
2 changes: 1 addition & 1 deletion components/language.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,4 +52,4 @@ const Language: React.FC<Props> = ({ children, top }) => {
)
}

export default Language
export default Language
2 changes: 1 addition & 1 deletion components/news-list.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -73,4 +73,4 @@ const NewsList: React.FC<Props> = ({ news }) => {
)
}

export default NewsList
export default NewsList
2 changes: 1 addition & 1 deletion components/ogimage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -105,4 +105,4 @@ const OgImage: FC<Props> = ({ title, desc, id }) => {
)
}

export default OgImage
export default OgImage
2 changes: 1 addition & 1 deletion components/unsplash.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,4 @@ const Unsplash: React.FC<Props> = ({ children, href, name }) => {
)
}

export default Unsplash
export default Unsplash
2 changes: 1 addition & 1 deletion lib/blog.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
QueryDatabaseParameters,
PersonUserObjectResponseEx,
ListBlockChildrenResponseEx,
} from 'notionate'
} from 'rotion'
import { buildPlainText } from './member'

type Writer = {
Expand Down
12 changes: 6 additions & 6 deletions lib/content.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ import {
GetPageResponseEx,
ListBlockChildrenResponseEx,
QueryDatabaseParameters,
} from 'notionate'
} from 'rotion'
import { buildPlainText } from './member'

type DBPage = DBPageBase & {
export type DBPage = DBPageBase & {
properties: {
Name: {
type: "title"
Expand Down Expand Up @@ -128,25 +128,25 @@ export const GetContent = async (slug: string, category?: string): Promise<Conte
let ja = null

if (pageEn) {
const blocksEn = await FetchBlocks(pageEn.id, pageEn.last_edited_time)
const blocksEn = await FetchBlocks({ block_id: pageEn.id, last_edited_time: pageEn.last_edited_time })
en = {
id: pageEn.id,
title: pageEn.properties.Name.title.map(v => v.plain_text).join(','),
cover: (pageEn.cover && 'src' in pageEn.cover) ? pageEn.cover.src : '',
page: await FetchPage(pageEn.id, pageEn.last_edited_time),
page: await FetchPage({ page_id: pageEn.id, last_edited_time: pageEn.last_edited_time }),
blocks: blocksEn,
excerpt: buildExcerpt(blocksEn),
last_edited_time: pageEn.last_edited_time,
} as Content
}

if (pageJa) {
const blocksJa = await FetchBlocks(pageJa.id, pageJa.last_edited_time)
const blocksJa = await FetchBlocks({ block_id: pageJa.id, last_edited_time: pageJa.last_edited_time })
ja = {
id: pageJa.id,
title: pageJa.properties.Name.title.map(v => v.plain_text).join(','),
cover: (pageJa.cover && 'src' in pageJa.cover) ? pageJa.cover.src : '',
page: await FetchPage(pageJa.id, pageJa.last_edited_time),
page: await FetchPage({ page_id: pageJa.id, last_edited_time: pageJa.last_edited_time }),
blocks: blocksJa,
excerpt: buildExcerpt(blocksJa),
last_edited_time: pageJa.last_edited_time,
Expand Down
4 changes: 2 additions & 2 deletions lib/dataset.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
FetchBlocks,
BlockObjectResponse,
CodeBlockObjectResponse,
} from 'notionate'
} from 'rotion'
import { Dataset, WithContext } from 'schema-dts'

const momlibid = process.env.NOTION_MOTHERLIBRARIES_DB_ID
Expand Down Expand Up @@ -113,7 +113,7 @@ type DBProps = DBPageBase & {
}

const GetSchema = async (block_id: string, last_edited_time: string): Promise<string> => {
const blocks = await FetchBlocks(block_id, last_edited_time)
const blocks = await FetchBlocks({ block_id, last_edited_time })
const { results } = blocks

const b = results.find(vv => {
Expand Down
Loading

0 comments on commit d3591bc

Please sign in to comment.