-
-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e734f97
commit d7ecb8b
Showing
4 changed files
with
85 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
name: Docker Build and Publish | ||
|
||
on: | ||
push: | ||
branches: [ "main" ] | ||
tags: [ "v*.*.*" ] | ||
pull_request: | ||
branches: [ "main" ] | ||
|
||
env: | ||
REGISTRY: ghcr.io | ||
IMAGE_NAME: ${{ github.repository }} | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
permissions: | ||
contents: read | ||
packages: write | ||
|
||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v4 | ||
|
||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v3 | ||
|
||
- name: Log into registry ${{ env.REGISTRY }} | ||
if: github.event_name != 'pull_request' | ||
uses: docker/login-action@v3 | ||
with: | ||
registry: ${{ env.REGISTRY }} | ||
username: ${{ github.actor }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: Extract Docker metadata | ||
id: meta | ||
uses: docker/metadata-action@v5 | ||
with: | ||
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} | ||
tags: | | ||
type=ref,event=branch | ||
type=ref,event=pr | ||
type=semver,pattern={{version}} | ||
type=semver,pattern={{major}}.{{minor}} | ||
type=semver,pattern={{major}} | ||
type=sha | ||
type=raw,value=latest,enable={{is_default_branch}} | ||
- name: Build and push Docker image | ||
uses: docker/build-push-action@v5 | ||
with: | ||
context: . | ||
push: ${{ github.event_name != 'pull_request' }} | ||
tags: ${{ steps.meta.outputs.tags }} | ||
labels: ${{ steps.meta.outputs.labels }} | ||
cache-from: type=gha | ||
cache-to: type=gha,mode=max |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +1,33 @@ | ||
export let requestIp: string; | ||
|
||
import { type Handle } from '@sveltejs/kit'; | ||
import { dev } from '$app/environment'; | ||
import { createInstance } from '$lib/pocketbase'; | ||
import { type Handle } from "@sveltejs/kit"; | ||
import { dev } from "$app/environment"; | ||
import { createInstance } from "$lib/pocketbase"; | ||
|
||
export const handle: Handle = async ({ event, resolve }) => { | ||
event.locals.pb = createInstance(); | ||
const cookie = event.request.headers.get('cookie') || ''; | ||
event.locals.pb.authStore.loadFromCookie(cookie); | ||
event.locals.pb.autoCancellation(false); | ||
event.locals.pb = createInstance(); | ||
const cookie = event.request.headers.get("cookie") || ""; | ||
event.locals.pb.authStore.loadFromCookie(cookie); | ||
|
||
try { | ||
if (event.locals.pb.authStore.isValid) { | ||
await event.locals.pb.collection('users').authRefresh(); | ||
event.locals.user = event.locals.pb.authStore.model; | ||
} else { | ||
console.log('Auth not valid'); | ||
} | ||
} catch (error) { | ||
console.error('Error refreshing auth:', error); | ||
event.locals.pb.authStore.clear(); | ||
} | ||
try { | ||
if (event.locals.pb.authStore.isValid) { | ||
await event.locals.pb.collection("users").authRefresh(); | ||
event.locals.user = event.locals.pb.authStore.model; | ||
} else { | ||
console.log("Auth not valid"); | ||
} | ||
} catch (error) { | ||
console.error("Error refreshing auth:", error); | ||
event.locals.pb.authStore.clear(); | ||
} | ||
|
||
const response = await resolve(event); | ||
const setCookie = event.locals.pb.authStore.exportToCookie({ | ||
sameSite: 'strict', | ||
secure: !dev, | ||
httpOnly: true | ||
}); | ||
response.headers.set('set-cookie', setCookie); | ||
const response = await resolve(event); | ||
const setCookie = event.locals.pb.authStore.exportToCookie({ | ||
sameSite: "strict", | ||
secure: !dev, | ||
httpOnly: true, | ||
}); | ||
response.headers.set("set-cookie", setCookie); | ||
|
||
return response; | ||
return response; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters