Skip to content

Commit b83c6de

Browse files
ci: Enables deploy CI (#13)
* ci: Enables deploy CI chore: Update CI chore: Add routeTree.gen.ts chore: Update for CI build chore: Enable deployment * chore: Enable preview urls * ci: Add pull request permissions and comment preview URL step * chore: Set an actual branch
1 parent fba07c8 commit b83c6de

9 files changed

Lines changed: 268 additions & 61 deletions

File tree

.github/actions/setup/action.yml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
name: setup
2+
3+
runs:
4+
using: composite
5+
steps:
6+
- uses: actions/checkout@08eba0b27e820071cde6df949e0beb9ba4906955 # v4.3.0
7+
with:
8+
fetch-depth: 2
9+
submodules: recursive
10+
- uses: pnpm/action-setup@41ff72655975bd51cab0327fa583b6e92b6d3061 # v4.2.0
11+
- uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0
12+
with:
13+
path: .turbo
14+
key: turbo-${{ runner.os }}-${{ runner.arch }}-${{ github.sha }}
15+
restore-keys: |
16+
turbo-${{ runner.os }}-${{ runner.arch }}-
17+
- uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
18+
with:
19+
node-version: 24
20+
cache: 'pnpm'
21+
- run: pnpm install
22+
shell: bash

.github/workflows/build-deploy.yml

Lines changed: 42 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: deploy
1+
name: build-deploy
22

33
on:
44
push:
@@ -12,22 +12,58 @@ on:
1212
workflow_dispatch:
1313

1414
jobs:
15-
setup:
16-
uses: vivliostyle/vivliostyle.pub/.github/workflows/setup.yml@main
17-
1815
build:
19-
needs: setup
2016
runs-on: ubuntu-latest
2117
permissions:
2218
contents: read
19+
outputs:
20+
preview: ${{ steps.build-env.outputs.preview }}
21+
preview-alias: ${{ steps.build-env.outputs.preview-alias }}
22+
hostname: ${{ steps.build-env.outputs.hostname }}
2323
steps:
24+
- uses: vivliostyle/vivliostyle.pub/.github/actions/setup@main
25+
- name: Determine build environment
26+
id: build-env
27+
run: |
28+
if [[ "${{ github.ref_name }}" == "main" ]]; then
29+
echo "preview=false" >> $GITHUB_OUTPUT
30+
echo "hostname=alpha.vivliostyle.pub" >> $GITHUB_OUTPUT
31+
else
32+
echo "preview=true" >> $GITHUB_OUTPUT
33+
echo "preview-alias=pr-preview-${{ github.event.number }}" >> $GITHUB_OUTPUT
34+
echo "hostname=pr-preview-${{ github.event.number }}-vivliostyle-pub-app.vivliostyle.workers.dev" >> $GITHUB_OUTPUT
35+
fi
2436
- run: pnpm build
37+
env:
38+
VITE_APP_HOSTNAME: ${{ steps.build-env.outputs.hostname }}
2539

2640
deploy:
27-
if: ${{ github.ref == 'refs/heads/main' }}
2841
needs: build
2942
runs-on: ubuntu-latest
3043
permissions:
3144
contents: read
45+
pull-requests: write
3246
steps:
47+
- uses: vivliostyle/vivliostyle.pub/.github/actions/setup@main
3348
- run: pnpm build
49+
env:
50+
VITE_APP_HOSTNAME: ${{ needs.build.outputs.hostname }}
51+
- name: Deploy production
52+
if: ${{ !fromJSON(needs.build.outputs.preview) }}
53+
run: npx wrangler deploy
54+
env:
55+
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}
56+
CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
57+
- name: Deploy preview
58+
if: ${{ fromJSON(needs.build.outputs.preview) }}
59+
run: npx wrangler versions upload --preview-alias ${{ needs.build.outputs.preview-alias }}
60+
env:
61+
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}
62+
CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
63+
- name: Comment preview URL
64+
if: ${{ fromJSON(needs.build.outputs.preview) }}
65+
uses: marocchino/sticky-pull-request-comment@773744901bac0e8cbb5a0dc842800d45e9b2b405 # v2.9.4
66+
with:
67+
header: preview-url
68+
message: |
69+
🚧 Preview URL: <https://${{ needs.build.outputs.hostname }}>

.github/workflows/setup.yml

Lines changed: 0 additions & 28 deletions
This file was deleted.

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ dist-ssr
2626

2727
.turbo
2828
*.tsbuildinfo
29-
*.gen.ts
3029
coverage/
3130
vivliostyle-pub/
3231
/secrets/*

biome.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,8 @@
3434
"includes": [
3535
"**",
3636
"!**/packages/cli-bundle/src/stubs/rollup/**/*",
37-
"!**/vivliostyle-pub/**/*"
37+
"!**/vivliostyle-pub/**/*",
38+
"!**/routeTree.gen.ts"
3839
]
3940
},
4041
"formatter": {

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
},
2323
"lint-staged": {
2424
"*": [
25-
"biome format --write --files-ignore-unknown=true"
25+
"biome format --write --files-ignore-unknown=true --no-errors-on-unmatched"
2626
]
2727
},
2828
"pnpm": {
Lines changed: 157 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,157 @@
1+
/* eslint-disable */
2+
3+
// @ts-nocheck
4+
5+
// noinspection JSUnusedGlobalSymbols
6+
7+
// This file was automatically generated by TanStack Router.
8+
// You should NOT make any changes in this file as it will be overwritten.
9+
// Additionally, you should also exclude this file from your linter and/or formatter to prevent it from being checked or modified.
10+
11+
// Import Routes
12+
13+
import { Route as rootRoute } from './routes/__root';
14+
import { Route as ThemeImport } from './routes/theme';
15+
import { Route as BibliographyImport } from './routes/bibliography';
16+
import { Route as IndexImport } from './routes/index';
17+
import { Route as EditContentIdImport } from './routes/edit/$contentId';
18+
19+
// Create/Update Routes
20+
21+
const ThemeRoute = ThemeImport.update({
22+
id: '/theme',
23+
path: '/theme',
24+
getParentRoute: () => rootRoute,
25+
} as any);
26+
27+
const BibliographyRoute = BibliographyImport.update({
28+
id: '/bibliography',
29+
path: '/bibliography',
30+
getParentRoute: () => rootRoute,
31+
} as any);
32+
33+
const IndexRoute = IndexImport.update({
34+
id: '/',
35+
path: '/',
36+
getParentRoute: () => rootRoute,
37+
} as any);
38+
39+
const EditContentIdRoute = EditContentIdImport.update({
40+
id: '/edit/$contentId',
41+
path: '/edit/$contentId',
42+
getParentRoute: () => rootRoute,
43+
} as any);
44+
45+
// Populate the FileRoutesByPath interface
46+
47+
declare module '@tanstack/react-router' {
48+
interface FileRoutesByPath {
49+
'/': {
50+
id: '/';
51+
path: '/';
52+
fullPath: '/';
53+
preLoaderRoute: typeof IndexImport;
54+
parentRoute: typeof rootRoute;
55+
};
56+
'/bibliography': {
57+
id: '/bibliography';
58+
path: '/bibliography';
59+
fullPath: '/bibliography';
60+
preLoaderRoute: typeof BibliographyImport;
61+
parentRoute: typeof rootRoute;
62+
};
63+
'/theme': {
64+
id: '/theme';
65+
path: '/theme';
66+
fullPath: '/theme';
67+
preLoaderRoute: typeof ThemeImport;
68+
parentRoute: typeof rootRoute;
69+
};
70+
'/edit/$contentId': {
71+
id: '/edit/$contentId';
72+
path: '/edit/$contentId';
73+
fullPath: '/edit/$contentId';
74+
preLoaderRoute: typeof EditContentIdImport;
75+
parentRoute: typeof rootRoute;
76+
};
77+
}
78+
}
79+
80+
// Create and export the route tree
81+
82+
export interface FileRoutesByFullPath {
83+
'/': typeof IndexRoute;
84+
'/bibliography': typeof BibliographyRoute;
85+
'/theme': typeof ThemeRoute;
86+
'/edit/$contentId': typeof EditContentIdRoute;
87+
}
88+
89+
export interface FileRoutesByTo {
90+
'/': typeof IndexRoute;
91+
'/bibliography': typeof BibliographyRoute;
92+
'/theme': typeof ThemeRoute;
93+
'/edit/$contentId': typeof EditContentIdRoute;
94+
}
95+
96+
export interface FileRoutesById {
97+
__root__: typeof rootRoute;
98+
'/': typeof IndexRoute;
99+
'/bibliography': typeof BibliographyRoute;
100+
'/theme': typeof ThemeRoute;
101+
'/edit/$contentId': typeof EditContentIdRoute;
102+
}
103+
104+
export interface FileRouteTypes {
105+
fileRoutesByFullPath: FileRoutesByFullPath;
106+
fullPaths: '/' | '/bibliography' | '/theme' | '/edit/$contentId';
107+
fileRoutesByTo: FileRoutesByTo;
108+
to: '/' | '/bibliography' | '/theme' | '/edit/$contentId';
109+
id: '__root__' | '/' | '/bibliography' | '/theme' | '/edit/$contentId';
110+
fileRoutesById: FileRoutesById;
111+
}
112+
113+
export interface RootRouteChildren {
114+
IndexRoute: typeof IndexRoute;
115+
BibliographyRoute: typeof BibliographyRoute;
116+
ThemeRoute: typeof ThemeRoute;
117+
EditContentIdRoute: typeof EditContentIdRoute;
118+
}
119+
120+
const rootRouteChildren: RootRouteChildren = {
121+
IndexRoute: IndexRoute,
122+
BibliographyRoute: BibliographyRoute,
123+
ThemeRoute: ThemeRoute,
124+
EditContentIdRoute: EditContentIdRoute,
125+
};
126+
127+
export const routeTree = rootRoute
128+
._addFileChildren(rootRouteChildren)
129+
._addFileTypes<FileRouteTypes>();
130+
131+
/* ROUTE_MANIFEST_START
132+
{
133+
"routes": {
134+
"__root__": {
135+
"filePath": "__root.tsx",
136+
"children": [
137+
"/",
138+
"/bibliography",
139+
"/theme",
140+
"/edit/$contentId"
141+
]
142+
},
143+
"/": {
144+
"filePath": "index.tsx"
145+
},
146+
"/bibliography": {
147+
"filePath": "bibliography.tsx"
148+
},
149+
"/theme": {
150+
"filePath": "theme.tsx"
151+
},
152+
"/edit/$contentId": {
153+
"filePath": "edit/$contentId.tsx"
154+
}
155+
}
156+
}
157+
ROUTE_MANIFEST_END */

packages/viola/vite.config.ts

Lines changed: 26 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ const serviceWorker = () => [
132132
];
133133

134134
// https://vite.dev/config/
135-
export default defineConfig(({ mode }) => {
135+
export default defineConfig(({ mode, command }) => {
136136
const env = loadEnv(mode, secretsDir);
137137

138138
return {
@@ -157,26 +157,31 @@ export default defineConfig(({ mode }) => {
157157
serveCli(),
158158
visualizer() as PluginOption,
159159
],
160-
server: {
161-
https: {
162-
key: fs.readFileSync(path.join(secretsDir, 'certs/privkey.pem')),
163-
cert: fs.readFileSync(path.join(secretsDir, 'certs/fullchain.pem')),
164-
},
165-
headers: {
166-
'Cross-Origin-Embedder-Policy': 'credentialless',
167-
'Cross-Origin-Opener-Policy': 'same-origin',
168-
'Cross-Origin-Resource-Policy': 'cross-origin',
169-
},
170-
allowedHosts: [
171-
// Leading dot allows any subdomains
172-
`.${env.VITE_APP_HOSTNAME}`,
173-
],
174-
cors: {
175-
origin: new RegExp(
176-
`^https?://([\\w-]+\\.)?${env.VITE_APP_HOSTNAME.replace('.', '\\.')}(?::\\d+)$`,
177-
),
178-
},
179-
},
160+
server:
161+
command === 'serve'
162+
? {
163+
https: {
164+
key: fs.readFileSync(path.join(secretsDir, 'certs/privkey.pem')),
165+
cert: fs.readFileSync(
166+
path.join(secretsDir, 'certs/fullchain.pem'),
167+
),
168+
},
169+
headers: {
170+
'Cross-Origin-Embedder-Policy': 'credentialless',
171+
'Cross-Origin-Opener-Policy': 'same-origin',
172+
'Cross-Origin-Resource-Policy': 'cross-origin',
173+
},
174+
allowedHosts: [
175+
// Leading dot allows any subdomains
176+
`.${env.VITE_APP_HOSTNAME}`,
177+
],
178+
cors: {
179+
origin: new RegExp(
180+
`^https?://([\\w-]+\\.)?${env.VITE_APP_HOSTNAME.replace('.', '\\.')}(?::\\d+)$`,
181+
),
182+
},
183+
}
184+
: undefined,
180185
envDir: secretsDir,
181186
};
182187
});

0 commit comments

Comments
 (0)