Skip to content

Commit c2ae643

Browse files
committed
add CI stuff
1 parent 95f0026 commit c2ae643

8 files changed

+169
-2
lines changed

.dockerignore

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
node_modules
2+
*.log*
3+
.nitro
4+
.cache
5+
.output
6+
.env
7+
dist

.github/workflows/linting.yml

+52
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
name: Linting and Testing
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
- dev
8+
pull_request:
9+
10+
jobs:
11+
linting:
12+
name: Run Linters
13+
runs-on: ubuntu-latest
14+
15+
steps:
16+
- name: Checkout code
17+
uses: actions/checkout@v3
18+
19+
- name: Install Node.js
20+
uses: actions/setup-node@v3
21+
with:
22+
node-version: 18
23+
cache: 'npm'
24+
25+
- name: Install npm packages
26+
run: npm install
27+
28+
- name: Prepare for linting
29+
run: npm run prepare
30+
31+
- name: Run ESLint
32+
run: npm lint
33+
34+
building:
35+
name: Build project
36+
runs-on: ubuntu-latest
37+
38+
steps:
39+
- name: Checkout code
40+
uses: actions/checkout@v3
41+
42+
- name: Install Node.js
43+
uses: actions/setup-node@v3
44+
with:
45+
node-version: 18
46+
cache: 'npm'
47+
48+
- name: Install npm packages
49+
run: npm install
50+
51+
- name: Build Project
52+
run: npm build

.github/workflows/publish.yml

+55
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
name: Docker Publish
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
8+
env:
9+
REGISTRY: ghcr.io
10+
IMAGE_NAME: ${{ github.repository }}
11+
12+
jobs:
13+
build:
14+
runs-on: ubuntu-latest
15+
permissions:
16+
contents: read
17+
packages: write
18+
id-token: write
19+
20+
steps:
21+
- name: Checkout repository
22+
uses: actions/checkout@v3
23+
24+
- name: Setup Docker buildx
25+
uses: docker/setup-buildx-action@v2
26+
27+
- name: Get version
28+
id: package-version
29+
uses: martinbeentjes/npm-get-version-action@main
30+
31+
- name: Log into registry ${{ env.REGISTRY }}
32+
uses: docker/login-action@v2
33+
with:
34+
registry: ${{ env.REGISTRY }}
35+
username: ${{ github.actor }}
36+
password: ${{ secrets.GITHUB_TOKEN }}
37+
38+
- name: Extract Docker metadata
39+
id: meta
40+
uses: docker/metadata-action@v4
41+
with:
42+
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
43+
flavor: |
44+
latest=auto
45+
tags: |
46+
type=semver,pattern={{version}},value=v${{ steps.package-version.outputs.current-version }}
47+
48+
- name: Build and push Docker image
49+
id: build-and-push
50+
uses: docker/build-push-action@v4
51+
with:
52+
push: true
53+
context: .
54+
labels: ${{ steps.meta.outputs.labels }}
55+
tags: ${{ steps.meta.outputs.tags }}

.github/workflows/release.yml

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
8+
jobs:
9+
release:
10+
name: Release
11+
runs-on: ubuntu-latest
12+
13+
steps:
14+
- name: Checkout code
15+
uses: actions/checkout@v3
16+
17+
- name: Get version
18+
id: package-version
19+
uses: martinbeentjes/npm-get-version-action@main
20+
21+
- name: Create Release
22+
id: create_release
23+
uses: actions/create-release@v1
24+
env:
25+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
26+
with:
27+
tag_name: v${{ steps.package-version.outputs.current-version }}
28+
release_name: Bot v${{ steps.package-version.outputs.current-version }}
29+
draft: false
30+
prerelease: false

Dockerfile

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
FROM node:18-alpine as base
2+
WORKDIR /app
3+
4+
# Build layer
5+
FROM base as build
6+
7+
COPY package-lock.json package.json ./
8+
RUN npm install --frozen-lockfile
9+
COPY . .
10+
RUN npm run build
11+
12+
# Production layer
13+
FROM base as production
14+
15+
EXPOSE 3000
16+
ENV NODE_ENV=production
17+
COPY --from=build /app/.output ./.output
18+
19+
CMD ["node", ".output/server/index.mjs"]

README.md

+5
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,8 @@ features:
1010
supported platforms:
1111
- cloudflare workers
1212
- nodejs
13+
14+
## Todos:
15+
- [ ] release with multi platform
16+
- [ ] Easy deploy to cloudflare button (just needs CI)
17+
- [ ] Test on cloudflare

package-lock.json

-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"prepare": "nitropack prepare",
77
"dev": "nitropack dev",
88
"build": "nitropack build",
9-
"preview": "node .output/server/index.mjs",
9+
"start": "node .output/server/index.mjs",
1010
"lint": "eslint --ext .js src/",
1111
"lint:fix": "eslint --fix --ext .js src/"
1212
},

0 commit comments

Comments
 (0)