Skip to content

Commit

Permalink
[Add] deploy spa for nuxt by github action
Browse files Browse the repository at this point in the history
  • Loading branch information
Thanonphat.su (DKKs) committed Apr 3, 2024
1 parent 5f65fb1 commit 83fb0f5
Show file tree
Hide file tree
Showing 3 changed files with 82 additions and 6 deletions.
70 changes: 70 additions & 0 deletions .github/workflows/deploy-spa.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
name: Deploy to GitHub Pages

on:
workflow_dispatch:
push:
branches:
- spa

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- run: corepack enable
- uses: actions/setup-node@v4
with:
node-version: "20"

- uses: pnpm/action-setup@v3
name: Install pnpm
with:
version: 8
run_install: false

- name: Get pnpm store directory
shell: bash
run: |
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV
- uses: actions/cache@v3
name: Setup pnpm cache
with:
path: ${{ env.STORE_PATH }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-
# Pick your own package manager and build script
- run: pnpm install
- run: pnpm generate
env:
NITRO_PRESET: github_pages

- name: Upload artifact
uses: actions/upload-pages-artifact@v3
with:
path: ./.output/public

# Deploy job
deploy:
# Add a dependency to the build job
needs: build

# Grant GITHUB_TOKEN the permissions required to make a Pages deployment
permissions:
pages: write # to deploy to Pages
id-token: write # to verify the deployment originates from an appropriate source

# Deploy to the github-pages environment
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}

# Specify runner + deployment step
runs-on: ubuntu-latest
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4 # or the latest "vX.X.X" version tag for this action

15 changes: 9 additions & 6 deletions nuxt.config.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
export default defineNuxtConfig({
ssr: false,

app: {
baseURL: '/nuxt3-vitesse-dkks',
head: {
viewport: 'width=device-width,initial-scale=1',
meta: [
Expand Down Expand Up @@ -39,7 +42,7 @@ export default defineNuxtConfig({
// i18n support
// comment if you don't want to use i18n.
i18n: {
vueI18n: './i18n.config.ts'
vueI18n: './i18n.config.ts',
},

imports: {
Expand All @@ -62,16 +65,16 @@ export default defineNuxtConfig({
tsConfig: {
include: ['./types/**/*.d.ts'],
},
shim: false
shim: false,
},

devtools: {
enabled: true
enabled: true,
},

runtimeConfig: {
public: {
WHAT_ENV: process.env.WHAT_ENV || 'env_dev'
}
}
WHAT_ENV: process.env.WHAT_ENV || 'env_dev',
},
},
})
3 changes: 3 additions & 0 deletions pages/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ const whatEnv = config.public.WHAT_ENV
</template>
</Suspense>
<LangSwitcher />
<div class="font-bold text-red-300">
SPA MODE
</div>
<div class="flex justify-center">
<ul
class="list-image-[url(data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTQiIGhlaWdodD0iMTIiIHZpZXdCb3g9IjAgMCAxNCAxMiIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiBmaWxsPSIjMzhiZGY4Ij48cGF0aCBmaWxsLXJ1bGU9ImV2ZW5vZGQiIGQ9Ik0xMy42ODUuMTUzYS43NTIuNzUyIDAgMCAxIC4xNDMgMS4wNTJsLTggMTAuNWEuNzUuNzUgMCAwIDEtMS4xMjcuMDc1bC00LjUtNC41YS43NS43NSAwIDAgMSAxLjA2LTEuMDZsMy44OTQgMy44OTMgNy40OC05LjgxN2EuNzUuNzUgMCAwIDEgMS4wNS0uMTQzWiIgLz48L3N2Zz4=)]"
Expand Down

0 comments on commit 83fb0f5

Please sign in to comment.