From a013466077fd93cf18cc79ae1d52dfb43b1db13d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christer=20War=C3=A9n?= Date: Fri, 1 Nov 2024 01:27:30 +0200 Subject: [PATCH] Initial Commit --- .github/dependabot.yml | 19 +++++++++++++++ .github/labeler.yml | 13 +++++++++++ .github/workflows/dependabot_auto-merge.yml | 20 ++++++++++++++++ .github/workflows/docker-build.yml | 22 +++++++++++++++++ .github/workflows/labeler.yml | 17 ++++++++++++++ .github/workflows/typescript-build.yml | 22 +++++++++++++++++ .gitignore | 3 +++ .vscode/settings.json | 6 +++++ Dockerfile | 14 +++++++++++ LICENSE | 21 +++++++++++++++++ README.md | 20 ++++++++++++++++ package.json | 26 +++++++++++++++++++++ tsconfig.json | 16 +++++++++++++ 13 files changed, 219 insertions(+) create mode 100644 .github/dependabot.yml create mode 100644 .github/labeler.yml create mode 100644 .github/workflows/dependabot_auto-merge.yml create mode 100644 .github/workflows/docker-build.yml create mode 100644 .github/workflows/labeler.yml create mode 100644 .github/workflows/typescript-build.yml create mode 100644 .gitignore create mode 100644 .vscode/settings.json create mode 100644 Dockerfile create mode 100644 LICENSE create mode 100644 README.md create mode 100644 package.json create mode 100644 tsconfig.json diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..091e06d --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,19 @@ +version: 2 +updates: + # GitHub Actions + - package-ecosystem: "github-actions" + directory: "/" + schedule: + interval: "daily" + target-branch: "develop" + labels: + - "dependencies" + + # npm + - package-ecosystem: "npm" + directory: "/" + schedule: + interval: "daily" + target-branch: "develop" + labels: + - "dependencies" diff --git a/.github/labeler.yml b/.github/labeler.yml new file mode 100644 index 0000000..8066760 --- /dev/null +++ b/.github/labeler.yml @@ -0,0 +1,13 @@ +dependencies: +- changed-files: + - any-glob-to-any-file: + - package-lock.json + +documentation: +- changed-files: + - any-glob-to-any-file: + - README.md + - SECURITY.md + - CONTRIBUTING.md + - LICENSE + - .env_example diff --git a/.github/workflows/dependabot_auto-merge.yml b/.github/workflows/dependabot_auto-merge.yml new file mode 100644 index 0000000..04a8c0b --- /dev/null +++ b/.github/workflows/dependabot_auto-merge.yml @@ -0,0 +1,20 @@ +name: Dependabot Auto-Merge +on: + pull_request_target: + branches: [ develop ] + +permissions: + pull-requests: write + contents: write + +jobs: + dependabot: + name: Dependabot Auto-Merge + runs-on: ubuntu-latest + if: ${{ github.actor == 'dependabot[bot]' }} + steps: + - name: Enable auto-merge for Dependabot PRs + run: gh pr merge --auto --merge "$PR_URL" + env: + PR_URL: ${{ github.event.pull_request.html_url }} + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/docker-build.yml b/.github/workflows/docker-build.yml new file mode 100644 index 0000000..979c96a --- /dev/null +++ b/.github/workflows/docker-build.yml @@ -0,0 +1,22 @@ +name: Docker Build + +on: + pull_request: + types: [opened, synchronize, reopened, assigned, edited, ready_for_review] + push: + workflow_dispatch: + +jobs: + buildx: + name: Docker Build + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + - name: Setup Docker Buildx + uses: docker/setup-buildx-action@v3.7.1 + id: buildx + with: + install: true + - name: Build + run: docker build . # will run buildx diff --git a/.github/workflows/labeler.yml b/.github/workflows/labeler.yml new file mode 100644 index 0000000..acf9821 --- /dev/null +++ b/.github/workflows/labeler.yml @@ -0,0 +1,17 @@ +name: Labeler +on: [pull_request] + +jobs: + label: + name: Labeler + runs-on: ubuntu-latest + if: ${{ github.actor != 'dependabot[bot]' }} + permissions: + contents: read + pull-requests: write + + steps: + - uses: actions/labeler@v5 + with: + repo-token: "${{ secrets.GITHUB_TOKEN }}" + sync-labels: true diff --git a/.github/workflows/typescript-build.yml b/.github/workflows/typescript-build.yml new file mode 100644 index 0000000..55e43a5 --- /dev/null +++ b/.github/workflows/typescript-build.yml @@ -0,0 +1,22 @@ +name: TypeScript Build + +on: + pull_request: + types: [opened, synchronize, reopened, assigned, edited, ready_for_review] + push: + workflow_dispatch: + +jobs: + tsc: + name: TypeScript Build + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: install node v22 + uses: actions/setup-node@v4 + with: + node-version: 22 + - name: npm install + run: npm install + - name: tsc + uses: icrawl/action-tsc@v1 diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..9553c33 --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +node_modules/ +npm-debug.log +.env diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..247bf3e --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,6 @@ +{ + "files.trimTrailingWhitespace": true, + "files.insertFinalNewline": true, + "files.trimFinalNewlines": true, + "editor.renderFinalNewline": false +} diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..850850d --- /dev/null +++ b/Dockerfile @@ -0,0 +1,14 @@ +FROM docker.io/node:22-alpine + +#Dependencies +RUN apk add --virtual .build-deps python3 make g++ gcc git + +WORKDIR /usr/src/app + +COPY / /usr/src/app/ + +RUN npm install + +RUN npm run build + +CMD [ "npm", "start" ] diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..ccff6b0 --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2024 Verkkopeliyhdistys Insomnia ry & Warén Group + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/README.md b/README.md new file mode 100644 index 0000000..8e5ada1 --- /dev/null +++ b/README.md @@ -0,0 +1,20 @@ +# Insomnia ID - Bot + +## Description +Verkkopeliyhdistys Insomnia ry - Identity Bot + +## Commands + +### Build Image + +`podman build -t ghcr.io/insomniafi/insid-bot` + +### Publish Image +`podman push ghcr.io/insomniafi/insid-bot` + +### Run Container + +`podman run --name insid-bot -d -e DISCORD_TOKEN= ghcr.io/insomniafi/insid-bot` + +### Update Dependencies +`podman run --name insid-bot -d -e DISCORD_TOKEN= -v "$PWD":/usr/src/app/ ghcr.io/insomniafi/insid-bot` diff --git a/package.json b/package.json new file mode 100644 index 0000000..d5a39a9 --- /dev/null +++ b/package.json @@ -0,0 +1,26 @@ +{ + "name": "insid-bot", + "version": "0.0.1", + "description": "Verkkopeliyhdistys Insomnia ry - Identity Bot", + "main": "index.js", + "scripts": { + "build": "rimraf ./build && tsc", + "start": "node --no-warnings build/index.js", + "start:dev": "rimraf ./build && tsc && node --no-warnings build/index.js" + }, + "author": "Christer Warén / Warén Group", + "license": "MIT", + "private": true, + "homepage": "https://insomnia.fi", + "dependencies": { + "discord.js": "^14.16.3" + }, + "devDependencies": { + "rimraf": "^6.0.1", + "typescript": "^5.6.3" + }, + "engines": { + "node": ">=22.0.0", + "npm": ">=10.0.0" + } +} diff --git a/tsconfig.json b/tsconfig.json new file mode 100644 index 0000000..98cc1a5 --- /dev/null +++ b/tsconfig.json @@ -0,0 +1,16 @@ +{ + "compilerOptions": { + "target": "ES2020", + "module": "commonjs", + "lib": ["esnext"], + "allowJs": true, + "outDir": "build", + "rootDir": "src", + "strict": true, + "noImplicitAny": true, + "esModuleInterop": true, + "resolveJsonModule": true, + "skipLibCheck": true + }, + "exclude": ["build", "node_modules", "datastore"] +}