Skip to content

Commit 567e7a7

Browse files
authored
chore: add workflows (#9)
* fix: middleware * chore: add log; worker ts * chore: github action auto build
1 parent 8cd392a commit 567e7a7

2 files changed

Lines changed: 55 additions & 2 deletions

File tree

.github/workflows/build.yml

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
name: Docker Build and Push
2+
3+
on:
4+
push:
5+
branches: [main]
6+
tags: ['v*']
7+
pull_request:
8+
branches: [main]
9+
10+
permissions:
11+
contents: read
12+
packages: write
13+
14+
jobs:
15+
build:
16+
runs-on: ubuntu-latest
17+
18+
steps:
19+
- name: Checkout code
20+
uses: actions/checkout@v4
21+
22+
- name: Set up Docker Buildx
23+
uses: docker/setup-buildx-action@v3
24+
25+
- name: Login to GitHub Container Registry
26+
if: github.event_name != 'pull_request'
27+
uses: docker/login-action@v3
28+
with:
29+
registry: ghcr.io
30+
username: ${{ github.repository_owner }}
31+
password: ${{ secrets.GITHUB_TOKEN }}
32+
33+
- name: Extract metadata for Docker
34+
id: meta
35+
uses: docker/metadata-action@v5
36+
with:
37+
images: ghcr.io/${{ github.repository }}
38+
tags: |
39+
type=ref,event=branch
40+
type=ref,event=pr
41+
type=semver,pattern={{version}}
42+
type=semver,pattern={{major}}.{{minor}}
43+
type=sha,format=short
44+
45+
- name: Build and push Docker image
46+
uses: docker/build-push-action@v5
47+
with:
48+
context: .
49+
push: ${{ github.event_name != 'pull_request' }}
50+
tags: ${{ steps.meta.outputs.tags }}
51+
labels: ${{ steps.meta.outputs.labels }}
52+
cache-from: type=gha
53+
cache-to: type=gha,mode=max

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
"build": "bun ./scripts/build.ts",
88
"build:main": "bun build --env=disable --outfile=dist/index.js --target=node --minify ./src/index.ts",
99
"build:worker": "bun build --outfile=dist/worker.js --target=node --minify ./src/worker/worker.ts",
10-
"start": "NODE_ENV=production node ./dist/index.js",
11-
"dev": "bun run scripts/dev.ts && bun run --watch src/index.ts",
10+
"start": "NODE_ENV=production node --env-file-if-exists=.env.local dist/index.js",
11+
"dev": "bun run --watch src/index.ts",
1212
"test": "vitest",
1313
"lint": "bun eslint --fix",
1414
"prettier": "prettier --write \"./**/*.{ts,js,json}\"",

0 commit comments

Comments
 (0)