Skip to content

Commit

Permalink
add github actions
Browse files Browse the repository at this point in the history
  • Loading branch information
enoy19 committed Aug 3, 2023
1 parent d331f5d commit fc5b7f4
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 1 deletion.
47 changes: 47 additions & 0 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
name: docker

on:
push:
branches:
- 'main'

env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}

jobs:
docker:
runs-on: ubuntu-latest

permissions:
contents: read
packages: write

steps:
-
name: Set up QEMU
uses: docker/setup-qemu-action@v2
-
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
-
name: Login to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
-
name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v4
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
-
name: Build and push
uses: docker/build-push-action@v4
with:
context: "{{defaultContext}}"
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
13 changes: 12 additions & 1 deletion src/lib/server/fileUtil.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
import { env } from "$env/dynamic/private";
import fs from "fs/promises";

if(!(await fileExists(env.SECRET_DATA_PATH))) {
await fs.mkdir(env.SECRET_DATA_PATH, {
recursive: true,
});
}

export async function storeObject(object: object, path: string) {
await fs.writeFile(getDataFilePathFor(path), JSON.stringify(object, undefined, 2));
}
Expand All @@ -12,7 +18,12 @@ export async function createEmptyJsonFileIfNotExists(path: string) {
}

export async function readJson(path: string) {
return JSON.parse((await fs.readFile(getDataFilePathFor(path))).toString());
try {
return JSON.parse((await fs.readFile(getDataFilePathFor(path))).toString());
} catch(e) {
console.warn(`${path} not found`);
return {};
}
}

async function createEmptyJsonFile(path: string) {
Expand Down

0 comments on commit fc5b7f4

Please sign in to comment.