Skip to content

Commit cb6935e

Browse files
refactor: enhance GitHub Actions workflow for SvelteKit deployment to GitHub Pages
1 parent befabc8 commit cb6935e

1 file changed

Lines changed: 42 additions & 15 deletions

File tree

.github/workflows/deploy.yml

Lines changed: 42 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,52 @@
1-
# This is a basic workflow to automatically build a Svelte app and deploy it to GitHub Pages
2-
3-
name: Deploy to GitHub Pages
1+
name: Deploy SvelteKit to GitHub Pages
42

53
on:
64
push:
7-
branches: [ main ]
8-
workflow_dispatch:
5+
branches:
6+
- main
7+
workflow_dispatch: # allow manual trigger
8+
9+
permissions:
10+
contents: read
11+
pages: write
12+
id-token: write
13+
14+
concurrency:
15+
group: "pages"
16+
cancel-in-progress: true
917

1018
jobs:
1119
build:
1220
runs-on: ubuntu-latest
21+
1322
steps:
14-
- uses: actions/checkout@v2
23+
- name: Checkout repository
24+
uses: actions/checkout@v4
1525

16-
- name: Install and Build
17-
run: |
18-
npm install
19-
npm run build
20-
21-
- name: Deploy to GitHub Pages
22-
uses: JamesIves/github-pages-deploy-action@4.1.5
26+
- name: Set up Node.js
27+
uses: actions/setup-node@v4
2328
with:
24-
branch: gh-pages
25-
folder: build
29+
node-version: 20
30+
cache: npm
31+
32+
- name: Install dependencies
33+
run: npm ci
34+
35+
- name: Build SvelteKit site
36+
run: npm run build
37+
38+
- name: Upload build output
39+
uses: actions/upload-pages-artifact@v3
40+
with:
41+
path: build
42+
43+
deploy:
44+
environment:
45+
name: github-pages
46+
url: ${{ steps.deployment.outputs.page_url }}
47+
runs-on: ubuntu-latest
48+
needs: build
49+
steps:
50+
- name: Deploy to GitHub Pages
51+
id: deployment
52+
uses: actions/deploy-pages@v4

0 commit comments

Comments
 (0)