diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml new file mode 100644 index 0000000..987aa7e --- /dev/null +++ b/.github/workflows/deploy.yml @@ -0,0 +1,57 @@ +name: Deploy to GitHub Pages + +on: + push: + branches: 'main' + +jobs: + build_site: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + + # If you're using pnpm, add this step then change the commands and cache key below to use `pnpm` + - name: Install pnpm + uses: pnpm/action-setup@v3 + with: + version: 8 + + - name: Install Node.js + uses: actions/setup-node@v4 + with: + node-version: 20 + cache: pnpm + + - name: Install dependencies + run: pnpm install + + - name: build + env: + # BASE_PATH: '/${{ github.event.repository.name }}' + BASE_PATH: '' + run: | + pnpm run build + + - name: Upload Artifacts + uses: actions/upload-pages-artifact@v3 + with: + # this should match the `pages` option in your adapter-static options + path: 'build/' + + deploy: + needs: build_site + runs-on: ubuntu-latest + + permissions: + pages: write + id-token: write + + environment: + name: github-pages + url: ${{ steps.deployment.outputs.page_url }} + + steps: + - name: Deploy + id: deployment + uses: actions/deploy-pages@v4 diff --git a/package.json b/package.json index d2eb1ab..73be1ff 100644 --- a/package.json +++ b/package.json @@ -19,6 +19,7 @@ "@iconify-json/flowbite": "^1.1.2", "@playwright/test": "^1.28.1", "@sveltejs/adapter-auto": "^3.0.0", + "@sveltejs/adapter-static": "^3.0.1", "@sveltejs/kit": "^2.0.0", "@sveltejs/vite-plugin-svelte": "^3.0.0", "@types/eslint": "^8.56.0", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 11e4cdb..e3b054b 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -14,6 +14,9 @@ devDependencies: '@sveltejs/adapter-auto': specifier: ^3.0.0 version: 3.1.1(@sveltejs/kit@2.5.1) + '@sveltejs/adapter-static': + specifier: ^3.0.1 + version: 3.0.1(@sveltejs/kit@2.5.1) '@sveltejs/kit': specifier: ^2.0.0 version: 2.5.1(@sveltejs/vite-plugin-svelte@3.0.2)(svelte@4.2.11)(vite@5.1.4) @@ -655,6 +658,14 @@ packages: import-meta-resolve: 4.0.0 dev: true + /@sveltejs/adapter-static@3.0.1(@sveltejs/kit@2.5.1): + resolution: {integrity: sha512-6lMvf7xYEJ+oGeR5L8DFJJrowkefTK6ZgA4JiMqoClMkKq0s6yvsd3FZfCFvX1fQ0tpCD7fkuRVHsnUVgsHyNg==} + peerDependencies: + '@sveltejs/kit': ^2.0.0 + dependencies: + '@sveltejs/kit': 2.5.1(@sveltejs/vite-plugin-svelte@3.0.2)(svelte@4.2.11)(vite@5.1.4) + dev: true + /@sveltejs/kit@2.5.1(@sveltejs/vite-plugin-svelte@3.0.2)(svelte@4.2.11)(vite@5.1.4): resolution: {integrity: sha512-TKj08o3mJCoQNLTdRdGkHPePTCPUGTgkew65RDqjVU3MtPVxljsofXQYfXndHfq0P7KoPRO/0/reF6HesU0Djw==} engines: {node: '>=18.13'} diff --git a/svelte.config.js b/svelte.config.js index c9c19b0..e6a3a62 100644 --- a/svelte.config.js +++ b/svelte.config.js @@ -1,4 +1,4 @@ -import adapter from '@sveltejs/adapter-auto'; +import adapter from '@sveltejs/adapter-static'; import { vitePreprocess } from '@sveltejs/vite-plugin-svelte'; /** @type {import('@sveltejs/kit').Config} */ @@ -11,7 +11,12 @@ const config = { // adapter-auto only supports some environments, see https://kit.svelte.dev/docs/adapter-auto for a list. // If your environment is not supported or you settled on a specific environment, switch out the adapter. // See https://kit.svelte.dev/docs/adapters for more information about adapters. - adapter: adapter() + adapter: adapter({ + fallback: '404.html', + }), + paths: { + base: process.argv.includes('dev') ? '' : process.env.BASE_PATH, + } } };