From 33f367be7dbaef42f18d9681081fce1192a03353 Mon Sep 17 00:00:00 2001 From: Sofia Merino Costa Date: Thu, 27 Jun 2024 18:18:02 +0100 Subject: [PATCH] github pages --- .github/workflows/deploy.yml | 56 ++++++++++++++++++++++++++++++++++++ static/.nojekyll | 0 svelte.config.js | 5 ++++ 3 files changed, 61 insertions(+) create mode 100644 .github/workflows/deploy.yml create mode 100644 static/.nojekyll diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml new file mode 100644 index 0000000..8acfe20 --- /dev/null +++ b/.github/workflows/deploy.yml @@ -0,0 +1,56 @@ +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: npm + + - name: Install dependencies + run: npm install + + - name: build + env: + BASE_PATH: '/my-svelte-portfolio' + run: | + npm 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 \ No newline at end of file diff --git a/static/.nojekyll b/static/.nojekyll new file mode 100644 index 0000000..e69de29 diff --git a/svelte.config.js b/svelte.config.js index 8fd7212..606dfab 100644 --- a/svelte.config.js +++ b/svelte.config.js @@ -1,6 +1,8 @@ import adapter from "@sveltejs/adapter-node"; import { vitePreprocess } from "@sveltejs/vite-plugin-svelte"; +const dev = process.argv.includes("dev"); + /** @type {import('@sveltejs/kit').Config} */ const config = { kit: { @@ -8,6 +10,9 @@ const config = { // 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(), + paths: { + base: dev ? "" : process.env.BASE_PATH, + }, }, preprocess: vitePreprocess(), };