Skip to content

Commit

Permalink
docs: improve deploy-to-github-pages action example (#10083)
Browse files Browse the repository at this point in the history
Co-authored-by: Ben McCann <[email protected]>
  • Loading branch information
CaptainCodeman and benmccann authored Oct 10, 2023
1 parent 67812ed commit b7f1d23
Showing 1 changed file with 9 additions and 13 deletions.
22 changes: 9 additions & 13 deletions documentation/docs/25-build-and-deploy/50-adapter-static.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,26 +84,23 @@ By default, `adapter-static` checks that either all pages and endpoints (if any)

When building for GitHub Pages, make sure to update [`paths.base`](configuration#paths) to match your repo name, since the site will be served from <https://your-username.github.io/your-repo-name> rather than from the root.

You will have to prevent GitHub's provided Jekyll from managing your site by putting an empty `.nojekyll` file in your `static` folder.

A config for GitHub Pages might look like the following:

```js
// @errors: 2307 2322
/// file: svelte.config.js
import adapter from '@sveltejs/adapter-static';

const dev = process.argv.includes('dev');

/** @type {import('@sveltejs/kit').Config} */
const config = {
kit: {
adapter: adapter(),
paths: {
base: dev ? '' : process.env.BASE_PATH,
}
adapter: adapter()
}
};

config.paths = { base: process.argv.includes('dev') ? '' : process.env.BASE_PATH }

export default config;
```

You can use GitHub actions to automatically deploy your site to GitHub Pages when you make a change. Here's an example workflow:
Expand Down Expand Up @@ -140,13 +137,12 @@ jobs:

- name: build
env:
BASE_PATH: '/your-repo-name'
BASE_PATH: '/${{ github.event.repository.name }}'
run: |
npm run build
touch build/.nojekyll
- name: Upload Artifacts
uses: actions/upload-pages-artifact@v1
uses: actions/upload-pages-artifact@v2
with:
# this should match the `pages` option in your adapter-static options
path: 'build/'
Expand All @@ -162,9 +158,9 @@ jobs:
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}

steps:
- name: Deploy
id: deployment
uses: actions/deploy-pages@v1
uses: actions/deploy-pages@v2
```

0 comments on commit b7f1d23

Please sign in to comment.