From dcdbd436017651dd56c58e82bceb7122a0b9900e Mon Sep 17 00:00:00 2001 From: Lena Fuhrimann <6780471+cloudlena@users.noreply.github.com> Date: Sun, 24 Mar 2024 23:20:10 +0100 Subject: [PATCH] Switch hosting to GitHub pages Fixes https://github.com/bespinian/bespinian.io/issues/58 Fixes https://github.com/bespinian/bespinian.io/issues/59 --- .github/workflows/main.yml | 51 +++++++++++++++------------- src/routes/+layout.ts | 1 + src/routes/customers/[slug]/+page.ts | 14 ++++++-- svelte.config.js | 4 +-- 4 files changed, 41 insertions(+), 29 deletions(-) create mode 100644 src/routes/+layout.ts diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index d3cacf74..9393a1e9 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -1,12 +1,10 @@ name: Lint, Build and Deploy on: - pull_request: - branches: - - main push: branches: - main + pull_request: jobs: lint: @@ -17,38 +15,45 @@ jobs: uses: actions/setup-node@v4 - name: Checkout repo uses: actions/checkout@v4 - - name: Audit dependencies - run: npm audit - name: Install dependencies run: npm ci - - name: Check code + - name: Check run: npm run check - - name: Lint code + - name: Lint run: npm run lint + build: - name: Build and Deploy - if: github.ref == 'refs/heads/main' && github.event_name == 'push' + name: Build needs: lint - environment: aws-production + if: github.ref == 'refs/heads/main' && github.event_name == 'push' runs-on: ubuntu-latest - env: - AWS_REGION: eu-central-1 steps: - name: Set up Node.js uses: actions/setup-node@v4 - with: - node-version: lts/* - check-latest: true - - name: Set up OpenTofu - uses: opentofu/setup-opentofu@v1 - name: Checkout repo uses: actions/checkout@v4 - name: Install dependencies run: npm ci - - name: Build application + - name: Build run: npm run build - - name: Deploy to production - run: npm run deploy - env: - AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} - AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} + - name: Upload artifact + uses: actions/upload-pages-artifact@v3 + with: + path: ./build + + deploy: + name: Deploy + needs: build + environment: + name: github-pages + url: ${{ steps.deployment.outputs.page_url }} + runs-on: ubuntu-latest + permissions: + pages: write + id-token: write + steps: + - name: Configure Deployment + uses: actions/configure-pages@v4 + - name: Deploy + id: deployment + uses: actions/deploy-pages@v4 diff --git a/src/routes/+layout.ts b/src/routes/+layout.ts new file mode 100644 index 00000000..189f71e2 --- /dev/null +++ b/src/routes/+layout.ts @@ -0,0 +1 @@ +export const prerender = true; diff --git a/src/routes/customers/[slug]/+page.ts b/src/routes/customers/[slug]/+page.ts index e30c971a..195717bc 100644 --- a/src/routes/customers/[slug]/+page.ts +++ b/src/routes/customers/[slug]/+page.ts @@ -14,7 +14,15 @@ import xovisLogo from '$lib/images/xovis.svg'; import cometGroupEn from '$lib/customers/comet-group-en.json'; import cometGroupDe from '$lib/customers/comet-group-de.json'; import cometGroupLogo from '$lib/images/comet-group.webp'; -import type { PageLoad } from './$types'; +import type { PageLoad, EntryGenerator } from './$types'; + +export const entries: EntryGenerator = () => [ + { slug: '20-minuten' }, + { slug: 'citech-sensors' }, + { slug: 'swisssign-group' }, + { slug: 'xovis' }, + { slug: 'comet-group' } +]; export const load: PageLoad = ({ params }) => { switch (params.slug) { @@ -58,7 +66,7 @@ export const load: PageLoad = ({ params }) => { logo: cometGroupLogo } }; + default: + throw error(404, `Customer ${params.slug} not found`); } - - throw error(404, 'Not found'); }; diff --git a/svelte.config.js b/svelte.config.js index a61436dc..2cbc11b3 100644 --- a/svelte.config.js +++ b/svelte.config.js @@ -8,9 +8,7 @@ const config = { preprocess: vitePreprocess(), kit: { - adapter: adapter({ - fallback: 'index.html' - }), + adapter: adapter(), csp: { directives: { 'default-src': ['self'],