Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add common library #45

Merged
merged 1 commit into from
Feb 21, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
22 changes: 21 additions & 1 deletion .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 All @@ -23,8 +39,8 @@ jobs:
cache-from: type=registry,ref=ghcr.io/toiki-org/toiki-build:latest
cache-to: type=inline
build-args: |
ARCH=linux/amd64
VITE_API_URL=${{ secrets.API_URL }}
COMMON_IMAGE=toiki-common:latest

- name: Build server
uses: docker/build-push-action@v2
Expand All @@ -34,6 +50,8 @@ jobs:
context: ./server
cache-from: type=registry,ref=ghcr.io/toiki-org/toiki-backend:latest
cache-to: type=inline
build-args: |
COMMON_IMAGE=toiki-common:latest

- name: Build bot
uses: docker/build-push-action@v2
Expand All @@ -43,3 +61,5 @@ jobs:
context: ./bot
cache-from: type=registry,ref=ghcr.io/toiki-org/toiki-bot:latest
cache-to: type=inline
build-args: |
COMMON_IMAGE=toiki-common:latest
8 changes: 7 additions & 1 deletion bot/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
FROM node:18-alpine as build
ARG COMMON_IMAGE=ghcr.io/toiki-org/toiki-common:latest

FROM $COMMON_IMAGE as common

FROM node:20-alpine as build
WORKDIR /app
COPY --from=common /app /common
COPY package.json ./
COPY yarn.lock ./
RUN yarn --frozen-lockfile
Expand All @@ -9,6 +14,7 @@ RUN yarn build
# stage to install only production deps
FROM node:18-alpine as deps
WORKDIR /app
COPY --from=common /app /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
Loading