-
Notifications
You must be signed in to change notification settings - Fork 0
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
Showing
11 changed files
with
220 additions
and
89 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,32 @@ | ||
name: Docker Publish | ||
|
||
on: | ||
workflow_dispatch: | ||
inputs: | ||
tag: | ||
description: "Tag for the Docker image" | ||
required: true | ||
default: "latest" | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
permissions: | ||
contents: read | ||
packages: write | ||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v2 | ||
|
||
- name: Log in to GitHub Container Registry | ||
uses: docker/login-action@v2 | ||
with: | ||
registry: ghcr.io | ||
username: ${{ github.actor }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: Build Docker image | ||
run: docker build -t ghcr.io/${{ github.repository }}:${{ github.event.inputs.tag }} . | ||
|
||
- name: Push Docker image | ||
run: docker push ghcr.io/${{ github.repository }}:${{ github.event.inputs.tag }} |
This file was deleted.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
services: | ||
app: | ||
image: ghcr.io/benjick/byedarr:latest | ||
env_file: | ||
- .env | ||
environment: | ||
- DATABASE_URL=postgresql://postgres:postgres@db:5432/postgres | ||
- CONFIG_PATH=/config/config.yml | ||
volumes: | ||
- ./config.yml:/config/config.yml | ||
restart: unless-stopped | ||
|
||
db: | ||
image: postgres:16-alpine | ||
environment: | ||
- POSTGRES_USER=postgres | ||
- POSTGRES_PASSWORD=postgres | ||
- POSTGRES_DB=postgres | ||
volumes: | ||
- postgres_data:/var/lib/postgresql/data | ||
restart: unless-stopped | ||
|
||
volumes: | ||
postgres_data: |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import { desc } from "drizzle-orm"; | ||
import { describe, expect, it } from "vitest"; | ||
|
||
import { boolean, envSchema } from "./envSchema"; | ||
|
||
describe("boolean", () => { | ||
it("should parse strings properly", () => { | ||
expect(boolean.parse("true")).toBe(true); | ||
expect(boolean.parse("false")).toBe(false); | ||
expect(boolean.parse("")).toBe(false); | ||
expect(boolean.parse("anything")).toBe(false); | ||
expect(boolean.parse(1)).toBe(true); | ||
expect(boolean.parse(0)).toBe(false); | ||
expect(boolean.parse(null)).toBe(false); | ||
expect(boolean.parse(undefined)).toBe(false); | ||
expect(boolean.parse(true)).toBe(true); | ||
expect(boolean.parse(false)).toBe(false); | ||
}); | ||
}); | ||
|
||
describe("envSchema", () => { | ||
it("should have defaults properly set", () => { | ||
const res = envSchema.parse({ | ||
DISCORD_BOT_TOKEN: "process.env.DISCORD_BOT_TOKEN", | ||
CONFIG_PATH: "process.env.CONFIG_PATH", | ||
}); | ||
expect(res.NODE_ENV).toBe("development"); | ||
expect(res.DRY_RUN).toBe(false); | ||
expect(res.DEBUG).toBe(false); | ||
expect(res.SKIP_MIGRATIONS).toBe(false); | ||
}); | ||
}); |
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,21 @@ | ||
import { z } from "zod"; | ||
|
||
export const boolean = z.preprocess((val) => { | ||
if (typeof val === "string" && val !== "true") return false; | ||
return val; | ||
}, z.coerce.boolean()); | ||
|
||
export const envSchema = z.object({ | ||
DISCORD_BOT_TOKEN: z.string(), | ||
CONFIG_PATH: z.string(), | ||
DATABASE_URL: z | ||
.string() | ||
.url() | ||
.default("postgres://postgres:postgres@localhost:5432/postgres"), | ||
SKIP_MIGRATIONS: boolean.default(false), | ||
DRY_RUN: boolean.default(false), | ||
DEBUG: boolean.default(false), | ||
NODE_ENV: z | ||
.enum(["development", "production", "test"]) | ||
.default("development"), | ||
}); |
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