Skip to content

Commit

Permalink
init
Browse files Browse the repository at this point in the history
  • Loading branch information
cm-ayf committed Oct 16, 2023
0 parents commit 76d15bf
Show file tree
Hide file tree
Showing 21 changed files with 5,134 additions and 0 deletions.
1 change: 1 addition & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
DISCORD_TOKEN=YOUR_TOKEN_HERE
26 changes: 26 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
"root": true,
"extends": [
"eslint:recommended",
"plugin:@typescript-eslint/recommended-type-checked",
"prettier"
],
"parser": "@typescript-eslint/parser",
"plugins": ["@typescript-eslint", "import"],
"parserOptions": {
"sourceType": "module",
"ecmaVersion": "latest"
},
"env": {
"node": true
},
"rules": {
"import/order": [
"error",
{
"alphabetize": { "order": "asc" },
"newlines-between": "never"
}
]
}
}
25 changes: 25 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
on:
pull_request:
branches: [main]
push:
branches: [main]

jobs:
ci:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: 18
cache: npm
- name: Install dependencies
run: npm install
- name: Check types
run: npm run tsc:check
- name: Check lint rules
run: npm run lint:check
- name: Check format
run: npm run format:check
49 changes: 49 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
on:
push:
branches: [main]
tags: [v*.*.*]

env:
IMAGE_NAME: om

jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Log in to the Container registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Docker Metadata
uses: docker/metadata-action@v4
id: metadata
with:
images: ghcr.io/discordjs-japan/${{ env.IMAGE_NAME }}
tags: |
type=ref,event=branch
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}
- name: Build and push Docker image
uses: docker/build-push-action@0565240e2d4ab88bba5387d719585280857ece09 # v5.0.0
with:
context: .
platforms: linux/amd64,linux/arm64
tags: ${{ steps.metadata.outputs.tags }}
labels: ${{ steps.metadata.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
.DS_Store
/node_modules
/dist
.env
.env.*
!.env.example
4 changes: 4 additions & 0 deletions .lintstagedrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"*.ts": ["eslint --fix", "prettier --write"],
"*.{json,yml}": ["prettier --write"]
}
1 change: 1 addition & 0 deletions .prettierrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
3 changes: 3 additions & 0 deletions .simple-git-hooks.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"pre-commit": "npx lint-staged"
}
3 changes: 3 additions & 0 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"recommendations": ["dbaeumer.vscode-eslint", "esbenp.prettier-vscode"]
}
20 changes: 20 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
FROM node:18 as builder

WORKDIR /app

COPY ./* ./

RUN npm install
RUN npm run build

FROM node:18-alpine as runner

WORKDIR /app
ENV NODE_ENV=production

COPY --from=builder /app/dist/main.js ./dist
COPY /app/package.json ./

RUN npm install

CMD ["node", "main.js"]
12 changes: 12 additions & 0 deletions build.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { build } from "esbuild";
import packageJson from "./package.json" assert { type: "json" };

await build({
entryPoints: ["src/main.ts"],
bundle: true,
outfile: "dist/main.js",
platform: "node",
format: "esm",
external: Object.keys(packageJson.dependencies),
minify: true,
});
Loading

0 comments on commit 76d15bf

Please sign in to comment.