Skip to content

Commit

Permalink
add CI stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
mrjvs committed Sep 13, 2023
1 parent 95f0026 commit c2ae643
Show file tree
Hide file tree
Showing 8 changed files with 169 additions and 2 deletions.
7 changes: 7 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
node_modules
*.log*
.nitro
.cache
.output
.env
dist
52 changes: 52 additions & 0 deletions .github/workflows/linting.yml
Original file line number Diff line number Diff line change
@@ -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
55 changes: 55 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -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 }}
30 changes: 30 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -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
19 changes: 19 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -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"]
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
1 change: 0 additions & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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/"
},
Expand Down

0 comments on commit c2ae643

Please sign in to comment.