Skip to content

Commit

Permalink
Switch hosting to GitHub pages
Browse files Browse the repository at this point in the history
Fixes #58
Fixes #59
  • Loading branch information
cloudlena committed Mar 24, 2024
1 parent a1e94aa commit dcdbd43
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 29 deletions.
51 changes: 28 additions & 23 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
name: Lint, Build and Deploy

on:
pull_request:
branches:
- main
push:
branches:
- main
pull_request:

jobs:
lint:
Expand All @@ -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
1 change: 1 addition & 0 deletions src/routes/+layout.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export const prerender = true;
14 changes: 11 additions & 3 deletions src/routes/customers/[slug]/+page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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');
};
4 changes: 1 addition & 3 deletions svelte.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,7 @@ const config = {
preprocess: vitePreprocess(),

kit: {
adapter: adapter({
fallback: 'index.html'
}),
adapter: adapter(),
csp: {
directives: {
'default-src': ['self'],
Expand Down

0 comments on commit dcdbd43

Please sign in to comment.