-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #72 from ist-bot-team/v2
- Loading branch information
Showing
58 changed files
with
8,020 additions
and
726 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,4 @@ | ||
node_modules/ | ||
data/ | ||
dist/ | ||
.husky/ |
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,23 @@ | ||
{ | ||
"env": { | ||
"es2021": true, | ||
"node": true | ||
}, | ||
"extends": [ | ||
"eslint:recommended", | ||
"plugin:@typescript-eslint/recommended", | ||
"prettier" | ||
], | ||
"parser": "@typescript-eslint/parser", | ||
"parserOptions": { | ||
"ecmaVersion": 12, | ||
"sourceType": "module" | ||
}, | ||
"plugins": ["@typescript-eslint"], | ||
"rules": { | ||
"@typescript-eslint/no-unused-vars": [ | ||
"error", | ||
{ "varsIgnorePattern": "^_" } | ||
] | ||
} | ||
} |
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,53 @@ | ||
# This workflow uses actions that are not certified by GitHub. | ||
# They are provided by a third-party and are governed by | ||
# separate terms of service, privacy policy, and support | ||
# documentation. | ||
|
||
name: Create and publish a Docker image | ||
|
||
on: | ||
release: | ||
types: [published] | ||
|
||
env: | ||
REGISTRY: ghcr.io | ||
IMAGE_NAME: ${{ github.repository }} | ||
|
||
jobs: | ||
build-and-push-image: | ||
runs-on: ubuntu-latest | ||
permissions: | ||
contents: read | ||
packages: write | ||
|
||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v2 | ||
|
||
- name: Log in to the Container registry | ||
uses: docker/login-action@f054a8b539a109f9f41c372932f1ae047eff08c9 | ||
with: | ||
registry: ${{ env.REGISTRY }} | ||
username: ${{ github.actor }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: Extract metadata (tags, labels) for Docker | ||
id: meta | ||
uses: docker/metadata-action@98669ae865ea3cffbcbaa878cf57c20bbf1c6c38 | ||
with: | ||
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} | ||
tags: | | ||
type=ref,event=branch | ||
type=ref,event=tag | ||
type=ref,event=pr | ||
type=semver,pattern={{version}} | ||
type=semver,pattern={{major}}.{{minor}} | ||
type=semver,pattern={{major}} | ||
- name: Build and push Docker image | ||
uses: docker/build-push-action@ad44023a93711e3deb337508980b4b5e9bcdc5dc | ||
with: | ||
context: . | ||
push: true | ||
tags: ${{ steps.meta.outputs.tags }} | ||
labels: ${{ steps.meta.outputs.labels }} |
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,2 +1,8 @@ | ||
.env | ||
.venv | ||
node_modules/ | ||
dist/ | ||
data/ | ||
docker-compose.yml | ||
|
||
.vscode | ||
|
||
shell.nix |
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 @@ | ||
_ |
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,4 @@ | ||
#!/bin/sh | ||
. "$(dirname "$0")/_/husky.sh" | ||
|
||
npx lint-staged |
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 @@ | ||
engine-strict=true |
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,2 @@ | ||
node_modules/ | ||
dist/ |
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,4 @@ | ||
{ | ||
"tabWidth": 4, | ||
"useTabs": true | ||
} |
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,22 @@ | ||
FROM node:16.17.0-alpine3.16 as ts-compiler | ||
ARG DATABASE_URL | ||
ENV DATABASE_URL ${DATABASE_URL} | ||
WORKDIR /app | ||
COPY package.json . | ||
COPY yarn.lock . | ||
RUN yarn install --frozen-lockfile | ||
COPY ./ ./ | ||
RUN yarn run prisma generate | ||
RUN yarn build | ||
|
||
FROM node:16.17.0-alpine3.16 | ||
ARG DATABASE_URL | ||
ENV DATABASE_URL ${DATABASE_URL} | ||
WORKDIR /app | ||
COPY --from=ts-compiler /app/package.json . | ||
COPY --from=ts-compiler /app/yarn.lock . | ||
COPY --from=ts-compiler /app/src/prisma ./src/prisma | ||
COPY --from=ts-compiler /app/dist ./dist | ||
RUN yarn install --prod --frozen-lockfile | ||
RUN yarn run prisma generate | ||
CMD [ "yarn", "start:docker" ] |
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,11 @@ | ||
FROM node:16.17.0-alpine3.16 | ||
ARG DATABASE_URL | ||
ENV DATABASE_URL ${DATABASE_URL} | ||
WORKDIR /app | ||
COPY package.json . | ||
COPY yarn.lock . | ||
RUN yarn install --frozen-lockfile | ||
COPY ./ ./ | ||
RUN yarn run prisma generate | ||
RUN yarn build | ||
CMD [ "yarn", "start:docker:dev" ] |
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 |
---|---|---|
@@ -1 +1,65 @@ | ||
# ist-discord-bot | ||
# IST Discord Bot | ||
|
||
![GitHub tag (latest by date)](https://img.shields.io/github/v/tag/ist-bot-team/ist-discord-bot?label=version) | ||
[![Discord](https://img.shields.io/discord/759576132227694642?label=discord&logo=discord)](https://discord.leic.pt) | ||
![GitHub](https://img.shields.io/github/license/ist-bot-team/ist-discord-bot) | ||
|
||
Discord bot to manage the IST Hub server -- join [here](https://discord.leic.pt). | ||
|
||
### Running | ||
|
||
#### Production | ||
|
||
1. Create a `docker-compose.yml` file as below: | ||
|
||
```yaml | ||
version: "3.8" | ||
|
||
services: | ||
ist-discord-bot: | ||
## EITHER: | ||
image: ghcr.io/ist-bot-team/ist-discord-bot:2 | ||
## OR: | ||
build: | ||
context: . | ||
dockerfile: Dockerfile.dev | ||
args: | ||
DATABASE_URL: file:/app/data/bot.db | ||
## END; | ||
volumes: | ||
- type: bind | ||
source: ./data | ||
target: /app/data | ||
environment: | ||
DISCORD_TOKEN: PLACE_BOT_TOKEN_HERE | ||
GUILD_ID: PLACE_MAIN_GUILD_ID_HERE # or "GLOBAL" to use in multiple guilds (1hr roll-out time) | ||
ADMIN_ID: PLACE_ADMIN_ROLE_ID_HERE | ||
ADMIN_PLUS_ID: PLACE_ADMIN_PLUS_ROLE_ID_HERE | ||
COMMAND_LOGS_CHANNEL_ID: PLACE_LOGGING_CHANNEL_ID_HERE | ||
TZ: Europe/Lisbon # default timezone for crontab and other date related stuff | ||
restart: unless-stopped | ||
``` | ||
2. Create a folder named `data` for Docker to store things in | ||
3. Run `docker-compose up -d --build` | ||
4. That's it! | ||
|
||
_You can also use `docker-compose down`, `docker-compose up`, `docker-compose restart` and `docker-compose logs [-f]`._ | ||
|
||
### Adding to a Server | ||
|
||
Replacing `CLIENT_ID` with the application's public ID, access the following link: | ||
|
||
``` | ||
https://discord.com/oauth2/authorize?client_id=CLIENT_ID&scope=bot+applications.commands&permissions=8 | ||
``` | ||
|
||
### Development | ||
|
||
If you're looking at the source code, you should probably run | ||
|
||
```sh | ||
npx prisma generate | ||
``` | ||
|
||
first so you can have typings. |
Oops, something went wrong.