add CI stuff
This commit is contained in:
parent
95f0026f5a
commit
c2ae6432ae
|
@ -0,0 +1,7 @@
|
|||
node_modules
|
||||
*.log*
|
||||
.nitro
|
||||
.cache
|
||||
.output
|
||||
.env
|
||||
dist
|
|
@ -0,0 +1,52 @@
|
|||
name: Linting and Testing
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
- dev
|
||||
pull_request:
|
||||
|
||||
jobs:
|
||||
linting:
|
||||
name: Run Linters
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v3
|
||||
|
||||
- name: Install Node.js
|
||||
uses: actions/setup-node@v3
|
||||
with:
|
||||
node-version: 18
|
||||
cache: 'npm'
|
||||
|
||||
- name: Install npm packages
|
||||
run: npm install
|
||||
|
||||
- name: Prepare for linting
|
||||
run: npm run prepare
|
||||
|
||||
- name: Run ESLint
|
||||
run: npm lint
|
||||
|
||||
building:
|
||||
name: Build project
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v3
|
||||
|
||||
- name: Install Node.js
|
||||
uses: actions/setup-node@v3
|
||||
with:
|
||||
node-version: 18
|
||||
cache: 'npm'
|
||||
|
||||
- name: Install npm packages
|
||||
run: npm install
|
||||
|
||||
- name: Build Project
|
||||
run: npm build
|
|
@ -0,0 +1,55 @@
|
|||
name: Docker Publish
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
|
||||
env:
|
||||
REGISTRY: ghcr.io
|
||||
IMAGE_NAME: ${{ github.repository }}
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
contents: read
|
||||
packages: write
|
||||
id-token: write
|
||||
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v3
|
||||
|
||||
- name: Setup Docker buildx
|
||||
uses: docker/setup-buildx-action@v2
|
||||
|
||||
- name: Get version
|
||||
id: package-version
|
||||
uses: martinbeentjes/npm-get-version-action@main
|
||||
|
||||
- name: Log into registry ${{ env.REGISTRY }}
|
||||
uses: docker/login-action@v2
|
||||
with:
|
||||
registry: ${{ env.REGISTRY }}
|
||||
username: ${{ github.actor }}
|
||||
password: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
- name: Extract Docker metadata
|
||||
id: meta
|
||||
uses: docker/metadata-action@v4
|
||||
with:
|
||||
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
|
||||
flavor: |
|
||||
latest=auto
|
||||
tags: |
|
||||
type=semver,pattern={{version}},value=v${{ steps.package-version.outputs.current-version }}
|
||||
|
||||
- name: Build and push Docker image
|
||||
id: build-and-push
|
||||
uses: docker/build-push-action@v4
|
||||
with:
|
||||
push: true
|
||||
context: .
|
||||
labels: ${{ steps.meta.outputs.labels }}
|
||||
tags: ${{ steps.meta.outputs.tags }}
|
|
@ -0,0 +1,30 @@
|
|||
name: Release
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
|
||||
jobs:
|
||||
release:
|
||||
name: Release
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v3
|
||||
|
||||
- name: Get version
|
||||
id: package-version
|
||||
uses: martinbeentjes/npm-get-version-action@main
|
||||
|
||||
- name: Create Release
|
||||
id: create_release
|
||||
uses: actions/create-release@v1
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
with:
|
||||
tag_name: v${{ steps.package-version.outputs.current-version }}
|
||||
release_name: Bot v${{ steps.package-version.outputs.current-version }}
|
||||
draft: false
|
||||
prerelease: false
|
|
@ -0,0 +1,19 @@
|
|||
FROM node:18-alpine as base
|
||||
WORKDIR /app
|
||||
|
||||
# Build layer
|
||||
FROM base as build
|
||||
|
||||
COPY package-lock.json package.json ./
|
||||
RUN npm install --frozen-lockfile
|
||||
COPY . .
|
||||
RUN npm run build
|
||||
|
||||
# Production layer
|
||||
FROM base as production
|
||||
|
||||
EXPOSE 3000
|
||||
ENV NODE_ENV=production
|
||||
COPY --from=build /app/.output ./.output
|
||||
|
||||
CMD ["node", ".output/server/index.mjs"]
|
|
@ -10,3 +10,8 @@ features:
|
|||
supported platforms:
|
||||
- cloudflare workers
|
||||
- nodejs
|
||||
|
||||
## Todos:
|
||||
- [ ] release with multi platform
|
||||
- [ ] Easy deploy to cloudflare button (just needs CI)
|
||||
- [ ] Test on cloudflare
|
||||
|
|
|
@ -8,7 +8,6 @@
|
|||
"name": "simple-proxy",
|
||||
"version": "2.0.0",
|
||||
"dependencies": {
|
||||
"h3": "^1.8.1",
|
||||
"nitropack": "latest"
|
||||
},
|
||||
"devDependencies": {
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
"prepare": "nitropack prepare",
|
||||
"dev": "nitropack dev",
|
||||
"build": "nitropack build",
|
||||
"preview": "node .output/server/index.mjs",
|
||||
"start": "node .output/server/index.mjs",
|
||||
"lint": "eslint --ext .js src/",
|
||||
"lint:fix": "eslint --fix --ext .js src/"
|
||||
},
|
||||
|
|
Loading…
Reference in New Issue