Skip to content

Commit 3417036

Browse files
committed
Add GitHub Actions workflow for deploying to GitHub Pages and update Svelte adapter to static
1 parent 8d6c88f commit 3417036

File tree

5 files changed

+88
-2
lines changed

5 files changed

+88
-2
lines changed

.github/workflows/deploy.yml

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
name: Deploy to GitHub Pages
2+
3+
on:
4+
push:
5+
branches: 'main'
6+
7+
jobs:
8+
build_site:
9+
runs-on: ubuntu-latest
10+
steps:
11+
- name: Checkout
12+
uses: actions/checkout@v4
13+
14+
# If you're using pnpm, add this step then change the commands and cache key below to use `pnpm`
15+
- name: Install pnpm
16+
uses: pnpm/action-setup@v3
17+
with:
18+
version: 9.15.3
19+
20+
- name: Install Node.js
21+
uses: actions/setup-node@v4
22+
with:
23+
node-version: 20
24+
cache: pnpm
25+
26+
- name: Install dependencies
27+
run: pnpm install
28+
29+
- name: build
30+
env:
31+
BASE_PATH: '/${{ github.event.repository.name }}'
32+
run: |
33+
pnpm run build
34+
35+
- name: Upload Artifacts
36+
uses: actions/upload-pages-artifact@v3
37+
with:
38+
# this should match the `pages` option in your adapter-static options
39+
path: 'build/'
40+
41+
deploy:
42+
needs: build_site
43+
runs-on: ubuntu-latest
44+
45+
permissions:
46+
pages: write
47+
id-token: write
48+
49+
environment:
50+
name: github-pages
51+
url: ${{ steps.deployment.outputs.page_url }}
52+
53+
steps:
54+
- name: Deploy
55+
id: deployment
56+
uses: actions/deploy-pages@v4

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,12 @@
5353
},
5454
"devDependencies": {
5555
"@sveltejs/adapter-auto": "^3.3.1",
56+
"@sveltejs/adapter-static": "^3.0.8",
5657
"@sveltejs/kit": "^2.15.1",
5758
"@sveltejs/package": "^2.3.7",
5859
"@sveltejs/vite-plugin-svelte": "^4.0.4",
5960
"autoprefixer": "^10.4.20",
61+
"i": "^0.3.7",
6062
"prettier": "^3.4.2",
6163
"prettier-plugin-svelte": "^3.3.2",
6264
"publint": "^0.2.12",

pnpm-lock.yaml

Lines changed: 21 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/routes/+layout.svelte

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
<script lang="ts">
22
import '../app.css';
33
let { children } = $props();
4+
export const prerender = true;
45
</script>
56

67
{@render children()}

svelte.config.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import adapter from '@sveltejs/adapter-auto';
1+
import adapter from '@sveltejs/adapter-static';
22
import { vitePreprocess } from '@sveltejs/vite-plugin-svelte';
33

44
/** @type {import('@sveltejs/kit').Config} */
@@ -11,7 +11,13 @@ const config = {
1111
// adapter-auto only supports some environments, see https://svelte.dev/docs/kit/adapter-auto for a list.
1212
// If your environment is not supported, or you settled on a specific environment, switch out the adapter.
1313
// See https://svelte.dev/docs/kit/adapters for more information about adapters.
14-
adapter: adapter()
14+
adapter: adapter({
15+
pages: 'build',
16+
assets: 'build'
17+
}),
18+
paths: {
19+
base: process.argv.includes('dev') ? '' : process.env.BASE_PATH
20+
}
1521
}
1622
};
1723

0 commit comments

Comments
 (0)