Skip to content

Commit c252d48

Browse files
committed
update action to split build and deploy, and only official GH actions
1 parent e4b3845 commit c252d48

1 file changed

Lines changed: 24 additions & 9 deletions

File tree

.github/workflows/static.yml

Lines changed: 24 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,16 @@ name: Deploy SvelteKit to GitHub Pages
22

33
on:
44
push:
5-
branches: [svelte-ssg]
5+
branches: [main]
66

7+
permissions:
8+
contents: read
9+
pages: write
10+
id-token: write
11+
12+
# 2 jobs: build the SvelteKit static site, and deploy the built site to GitHub Pages
713
jobs:
8-
build-and-deploy:
14+
build:
915
runs-on: ubuntu-latest
1016

1117
steps:
@@ -18,17 +24,26 @@ jobs:
1824
node-version-file: .nvmrc
1925
cache: npm # cache node_modules for faster builds
2026

21-
# Install dependencies exactly as in package-lock.json
2227
- name: Install dependencies
23-
run: npm ci
28+
run: npm ci # ci (not install) to install exact versions from package-lock.json
2429

2530
# Build the SvelteKit project
2631
- name: Build project
2732
run: npm run build
2833

29-
# Upload the build output to GitHub Pages
30-
- name: Deploy to GitHub Pages
31-
uses: peaceiris/actions-gh-pages@v4
34+
# Upload build output as artifact
35+
- uses: actions/upload-pages-artifact@v3
3236
with:
33-
github_token: ${{ secrets.GITHUB_TOKEN }}
34-
publish_dir: ./build # SvelteKit static output folder
37+
path: ./build # SvelteKit static output folder
38+
39+
deploy:
40+
needs: build # make the build artifact available here in deploy job
41+
runs-on: ubuntu-latest
42+
43+
environment:
44+
name: github-pages
45+
url: ${{ steps.deploy.outputs.page_url }} # just a convenience, adds page url to action summary page
46+
47+
steps:
48+
- id: deploy
49+
uses: actions/deploy-pages@v4

0 commit comments

Comments
 (0)