Skip to content

Commit

Permalink
feat: add common library
Browse files Browse the repository at this point in the history
  • Loading branch information
Elbarae1921 committed Feb 18, 2025
1 parent b0ca36e commit 4ca713e
Show file tree
Hide file tree
Showing 24 changed files with 1,048 additions and 518 deletions.
13 changes: 13 additions & 0 deletions .github/workflows/build_deploy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,15 @@ jobs:
filters: |
bot:
- 'bot/**'
- 'common/**'
- '.github/workflows/**'
server:
- 'server/**'
- 'common/**'
- '.github/workflows/**'
client:
- 'client/**'
- 'common/**'
- '.github/workflows/**'
nginx:
- 'nginx/**'
Expand All @@ -44,6 +47,16 @@ jobs:
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build toiki-common
if: steps.filter.outputs.common == 'true'
uses: docker/build-push-action@v2
with:
tags: ghcr.io/toiki-org/toiki-common:latest
push: true
context: ./common
cache-from: type=registry,ref=ghcr.io/toiki-org/toiki-common:latest
cache-to: type=inline

- name: Build toiki-build
if: steps.filter.outputs.client == 'true'
uses: docker/build-push-action@v2
Expand Down
16 changes: 16 additions & 0 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,22 @@ jobs:
- name: Checkout
uses: actions/checkout@v1

- name: Login to DockerHub
uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build common
uses: docker/build-push-action@v2
with:
tags: toiki-common
push: false
context: ./common
cache-from: type=registry,ref=ghcr.io/toiki-org/toiki-common:latest
cache-to: type=inline

- name: Build client
uses: docker/build-push-action@v2
with:
Expand Down
4 changes: 3 additions & 1 deletion bot/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
FROM node:18-alpine as build
FROM node:20-alpine as build
WORKDIR /app
COPY --from=ghcr.io/toiki-org/toiki-common:latest /app/build /common
COPY package.json ./
COPY yarn.lock ./
RUN yarn --frozen-lockfile
Expand All @@ -9,6 +10,7 @@ RUN yarn build
# stage to install only production deps
FROM node:18-alpine as deps
WORKDIR /app
COPY --from=ghcr.io/toiki-org/toiki-common:latest /app/build /common
ENV NODE_ENV=production
COPY package.json ./
COPY yarn.lock ./
Expand Down
1 change: 1 addition & 0 deletions bot/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
"axios": "^1.6.7",
"discord.js": "^14.12.1",
"dotenv": "^16.0.3",
"toiki-common": "../common",
"yup": "^0.32.11"
},
"devDependencies": {
Expand Down
2 changes: 1 addition & 1 deletion bot/src/lib/core/processUrl.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as yup from 'yup';
import { isYoutubeOrSpotify } from '../../utils/isYoutubeOrSpotify';
import { isYoutubeOrSpotify } from 'toiki-common';
import { convertUrl } from '../../api/convertUrl';
import { ActionRowBuilder, ButtonBuilder } from 'discord.js';
import { interactionButtons } from '../interactions';
Expand Down
67 changes: 0 additions & 67 deletions bot/src/utils/isYoutubeOrSpotify.ts

This file was deleted.

Loading

0 comments on commit 4ca713e

Please sign in to comment.