Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 53666f7

Browse files
authored
Svelte deployment for GH Pages
1 parent 4f76c04 commit 53666f7

File tree

1 file changed

+82
-0
lines changed

1 file changed

+82
-0
lines changed

.github/workflows/svelte.yml

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
# Sample workflow for building and deploying a Svelte site to GitHub Pages
2+
#
3+
#
4+
name: Deploy Svelte site to Pages
5+
6+
on:
7+
# Runs on pushes targeting the default branch
8+
push:
9+
branches: ["main"]
10+
11+
# Allows you to run this workflow manually from the Actions tab
12+
workflow_dispatch:
13+
14+
# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
15+
permissions:
16+
contents: read
17+
pages: write
18+
id-token: write
19+
20+
# Allow one concurrent deployment
21+
concurrency:
22+
group: "pages"
23+
cancel-in-progress: true
24+
25+
jobs:
26+
# Build job
27+
build:
28+
runs-on: ubuntu-latest
29+
steps:
30+
- name: Checkout
31+
uses: actions/checkout@v3
32+
- name: Detect package manager
33+
id: detect-package-manager
34+
run: |
35+
if [ -f "${{ github.workspace }}/yarn.lock" ]; then
36+
echo "::set-output name=manager::yarn"
37+
echo "::set-output name=command::install"
38+
exit 0
39+
elif [ -f "${{ github.workspace }}/package.json" ]; then
40+
echo "::set-output name=manager::npm"
41+
echo "::set-output name=command::ci"
42+
exit 0
43+
else
44+
echo "Unable to determine packager manager"
45+
exit 1
46+
fi
47+
- name: Setup Node
48+
uses: actions/setup-node@v3
49+
with:
50+
node-version: "16"
51+
cache: ${{ steps.detect-package-manager.outputs.manager }}
52+
- name: Setup Pages
53+
uses: actions/configure-pages@v2
54+
- name: Restore cache
55+
uses: actions/cache@v3
56+
with:
57+
path: |
58+
dist
59+
.nuxt
60+
key: ${{ runner.os }}-nuxt-build-${{ hashFiles('dist') }}
61+
restore-keys: |
62+
${{ runner.os }}-nuxt-build-
63+
- name: Install dependencies
64+
run: ${{ steps.detect-package-manager.outputs.manager }} ${{ steps.detect-package-manager.outputs.command }}
65+
- name: Static HTML export with Svelte
66+
run: ${{ steps.detect-package-manager.outputs.manager }} run build
67+
- name: Upload artifact
68+
uses: actions/upload-pages-artifact@v1
69+
with:
70+
path: ./dist
71+
72+
# Deployment job
73+
deploy:
74+
environment:
75+
name: github-pages
76+
url: ${{ steps.deployment.outputs.page_url }}
77+
runs-on: ubuntu-latest
78+
needs: build
79+
steps:
80+
- name: Deploy to GitHub Pages
81+
id: deployment
82+
uses: actions/deploy-pages@v1

0 commit comments

Comments
 (0)