Add vercel deploy workflows for readest org

This commit is contained in:
chrox
2024-12-24 13:05:32 +01:00
parent a074542e96
commit 447eb09272
8 changed files with 61 additions and 11 deletions
+23
View File
@@ -0,0 +1,23 @@
name: Deploy to vercel on merge
on:
push:
branches:
- main
permissions:
contents: write
deployments: write
pull-requests: write
jobs:
build_and_deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
submodules: 'true'
- uses: amondnet/vercel-action@v25
with:
vercel-token: ${{ secrets.VERCEL_TOKEN }}
github-token: ${{ secrets.GITHUB_TOKEN }}
vercel-args: '--prod'
vercel-org-id: ${{ secrets.ORG_ID}}
vercel-project-id: ${{ secrets.PROJECT_ID}}
+25
View File
@@ -0,0 +1,25 @@
name: Create vercel preview URL on pull request
on:
pull_request:
branches: [main, master]
permissions:
contents: write
deployments: write
pull-requests: write
jobs:
build_and_deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
submodules: 'true'
- uses: amondnet/vercel-action@v25
id: vercel-deploy
with:
vercel-token: ${{ secrets.VERCEL_TOKEN }}
github-token: ${{ secrets.GITHUB_TOKEN }}
vercel-org-id: ${{ secrets.ORG_ID}}
vercel-project-id: ${{ secrets.PROJECT_ID}}
- name: preview-url
run: |
echo ${{ steps.vercel-deploy.outputs.preview-url }}
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "@readest/readest-app",
"version": "0.8.3",
"version": "0.8.5",
"private": true,
"scripts": {
"dev": "dotenv -e .env.tauri -- next dev",
+1
View File
@@ -25,6 +25,7 @@ export default function RootLayout({ children }: { children: React.ReactNode })
<meta name='apple-mobile-web-app-status-bar-style' content='default' />
<meta name='viewport' content='width=device-width, initial-scale=1, maximum-scale=1' />
<link rel='apple-touch-icon' sizes='180x180' href='/apple-touch-icon.png' />
<link rel='icon' href='/favicon.ico' />
<meta name='description' content={description} />
<meta property='og:url' content={url} />
<meta property='og:type' content='website' />
@@ -39,7 +39,7 @@ const FoliateViewer: React.FC<{
return () => clearTimeout(timer);
}, [toastMessage]);
useProgressSync(bookKey, config, setToastMessage);
useProgressSync(bookKey, setToastMessage);
const progressRelocateHandler = (event: Event) => {
const detail = (event as CustomEvent).detail;
@@ -34,7 +34,7 @@ const SearchBar: React.FC<SearchBarProps> = ({
const view = getView(bookKey)!;
const config = getConfig(bookKey)!;
const progress = getProgress(bookKey)!;
const searchConfig = config.searchConfig!;
const searchConfig = config.searchConfig! as BookSearchConfig;
const queuedSearchTerm = useRef('');
const isSearchPending = useRef(false);
@@ -10,17 +10,18 @@ import { useSettingsStore } from '@/store/settingsStore';
export const useProgressSync = (
bookKey: string,
config: BookConfig,
setToastMessage?: React.Dispatch<React.SetStateAction<string>>,
) => {
const { setConfig } = useBookDataStore();
const { getConfig, setConfig } = useBookDataStore();
const { getView } = useReaderStore();
const { settings } = useSettingsStore();
const { syncedConfigs, syncConfigs } = useSync();
const { user } = useAuth();
const view = getView(bookKey);
const config = getConfig(bookKey);
const pushConfig = (bookKey: string, config: BookConfig) => {
const pushConfig = (bookKey: string, config: BookConfig | null) => {
if (!config || !user) return;
const bookHash = bookKey.split('-')[0]!;
const newConfig = { bookHash, ...config };
const compressedConfig = JSON.parse(
@@ -30,7 +31,7 @@ export const useProgressSync = (
};
useEffect(() => {
if (!user) return;
if (!config || !user) return;
const bookHash = bookKey.split('-')[0]!;
syncConfigs([], bookHash, 'pull');
return () => {
@@ -42,7 +43,7 @@ export const useProgressSync = (
const lastProgressSyncTime = useRef<number>(0);
const syncTimeoutRef = useRef<ReturnType<typeof setTimeout> | null>(null);
useEffect(() => {
if (!user) return;
if (!config || !user) return;
const now = Date.now();
const timeSinceLastSync = now - lastProgressSyncTime.current;
if (configSynced.current && timeSinceLastSync > SYNC_PROGRESS_INTERVAL_SEC * 1000) {
@@ -75,9 +76,9 @@ export const useProgressSync = (
);
setConfig(bookKey, { ...config, ...newConfig });
configSynced.current = true;
if ((syncedConfig.progress?.[1] ?? 0) > 0 && (config.progress?.[1] ?? 0) > 0) {
if ((syncedConfig.progress?.[1] ?? 0) > 0 && (config?.progress?.[1] ?? 0) > 0) {
const syncedFraction = syncedConfig.progress![0] / syncedConfig.progress![1];
const configFraction = config.progress![0] / config.progress![1];
const configFraction = config!.progress![0] / config!.progress![1];
if (syncedFraction > configFraction) {
view?.goToFraction(syncedFraction);
setToastMessage?.('Progress synced');
+1 -1
View File
@@ -1,7 +1,7 @@
{
"name": "@readest/monorepo",
"private": true,
"repository": "chrox/readest",
"repository": "readest/readest",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"tauri": "pnpm --filter @readest/readest-app tauri"