Skip to content

Commit f328516

Browse files
committed
build: Update husky to version 9.1.4 and add prepare script for husky
1 parent 33e1feb commit f328516

File tree

6 files changed

+188
-0
lines changed

6 files changed

+188
-0
lines changed

.github/workflows/ci.yml

Lines changed: 161 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,161 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [main]
6+
pull_request:
7+
8+
env:
9+
# app
10+
APP_PORT: 80
11+
APP_ENV: 'development'
12+
APP_URL: 'localhost'
13+
14+
# redis
15+
REDIS_HOST: 'redis'
16+
REDIS_PORT: 6379
17+
REDIS_PASSWORD: 'password'
18+
19+
# database
20+
DB_PORT: 5432
21+
DB_HOST: 'postgres'
22+
DB_USERNAME: 'username'
23+
DB_PASSWORD: 'password'
24+
DB_DATABASE: 'database'
25+
26+
# email
27+
EMAIL_HOST: 'mailhot'
28+
EMAIL_PORT: 1025
29+
EMAIL_ALIAS: 'mail@jaw.dev'
30+
EMAIL_AUTH_EMAIL: 'name@email.com'
31+
EMAIL_AUTH_PASS: 'password'
32+
33+
# twilio
34+
TWILIO_ACCOUNT_SID: ''
35+
TWILIO_AUTH_TOKEN: ''
36+
TWILIO_FROM_PHONE_NUMBER: ''
37+
TWILIO_PHONE_NUMBER: ''
38+
39+
jobs:
40+
test:
41+
name: Unit tests
42+
runs-on: ubuntu-latest
43+
44+
strategy:
45+
matrix:
46+
node-version: [22.x]
47+
48+
steps:
49+
- uses: actions/checkout@v3
50+
- name: Use Node.js ${{ matrix.node-version }}
51+
uses: actions/setup-node@v3
52+
with:
53+
node-version: ${{ matrix.node-version }}
54+
cache: 'npm'
55+
56+
- name: Create .env file from .env.example
57+
run: cp .env.example .env
58+
59+
- name: Install dependencies
60+
run: npm i
61+
62+
- name: Test codes
63+
run: npm run test:coverage
64+
65+
lint:
66+
name: ESLint
67+
runs-on: ubuntu-latest
68+
69+
strategy:
70+
matrix:
71+
node-version: [22.x]
72+
73+
steps:
74+
- uses: actions/checkout@v3
75+
- name: Use Node.js ${{ matrix.node-version }}
76+
uses: actions/setup-node@v3
77+
with:
78+
node-version: ${{ matrix.node-version }}
79+
cache: 'npm'
80+
81+
- name: Install dependencies
82+
run: npm i
83+
84+
- name: Lint codes
85+
run: npm run lint
86+
87+
format:
88+
needs: [lint, test]
89+
name: Prettier format
90+
runs-on: ubuntu-latest
91+
92+
permissions:
93+
contents: write
94+
95+
strategy:
96+
matrix:
97+
node-version: [22.x]
98+
99+
steps:
100+
- uses: actions/checkout@v3
101+
- name: Use Node.js ${{ matrix.node-version }}
102+
uses: actions/setup-node@v3
103+
with:
104+
node-version: ${{ matrix.node-version }}
105+
cache: 'npm'
106+
107+
- name: Install dependencies
108+
run: npm i
109+
110+
- name: Format codes
111+
run: npm run format
112+
113+
- name: Commit changes
114+
uses: stefanzweifel/git-auto-commit-action@v4
115+
with:
116+
commit_message: 'style: format codes'
117+
env:
118+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
119+
120+
# deploy:
121+
# needs: [test, lint, format]
122+
# name: Deploy to Production
123+
# runs-on: ubuntu-latest
124+
# if: github.event_name == 'push' && github.ref == 'refs/heads/main'
125+
126+
# environment:
127+
# name: production
128+
# url: https://commit.jaw.dev/
129+
130+
# steps:
131+
# - name: Check out repository
132+
# uses: actions/checkout@v3
133+
134+
# - name: Set up Docker Buildx
135+
# uses: docker/setup-buildx-action@v2
136+
137+
# - name: Login to Container Registry
138+
# uses: docker/login-action@v2
139+
# with:
140+
# registry: ghcr.io
141+
# username: ${{ github.repository_owner }}
142+
# password: ${{ secrets.GH_TOKEN }}
143+
144+
# - name: Preset Image Name
145+
# run: echo "IMAGE_URL=$(echo ghcr.io/${{ github.repository_owner }}/${{ github.event.repository.name }}:$(echo ${{ github.sha }} | cut -c1-7) | tr '[:upper:]' '[:lower:]')" >> $GITHUB_ENV
146+
147+
# - name: Build and push Docker Image
148+
# uses: docker/build-push-action@v4
149+
# with:
150+
# context: .
151+
# file: ./Dockerfile.prod
152+
# push: true
153+
# tags: ${{ env.IMAGE_URL }}
154+
155+
# - name: Deploy Image to Server
156+
# uses: caprover/deploy-from-github@v1.1.2
157+
# with:
158+
# server: '${{ secrets.CAPROVER_SERVER }}'
159+
# app: '${{ secrets.APP_NAME }}'
160+
# token: '${{ secrets.APP_TOKEN }}'
161+
# image: ${{ env.IMAGE_URL }}

.husky/pre-push

100644100755
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#!/usr/bin/env sh
2+
. "$(dirname -- "$0")/_/husky.sh"
3+
4+
npm run format
5+
npm run lint
6+
npm run test

docs/contribution.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# 🤝 Contribution

docs/development.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# 💻 Development

package-lock.json

Lines changed: 17 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
"description": "send notification to discord, email, and sms",
55
"main": "index.js",
66
"scripts": {
7+
"prepare": "husky",
78
"start": "node --no-warnings ./dist/src/server.js",
89
"dev": "tsx watch --no-warnings --clear-screen=false ./src/server.ts",
910
"build": "tsc",
@@ -60,6 +61,7 @@
6061
"@typescript-eslint/parser": "^7.16.1",
6162
"eslint-config-prettier": "^9.1.0",
6263
"eslint-plugin-prettier": "^5.2.1",
64+
"husky": "^9.1.4",
6365
"ioredis-mock": "^8.9.0",
6466
"prettier": "^3.3.3",
6567
"tsx": "^4.16.5",

0 commit comments

Comments
 (0)