Created CI/CD workflow

This commit is contained in:
Ceferino Patino 2024-02-17 22:08:24 -06:00
commit 469204a30f
11 changed files with 9704 additions and 13663 deletions

View file

@ -1,38 +0,0 @@
# This workflow will do a clean installation of node dependencies, cache/restore them, build the source code and run tests across different versions of node
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions
name: Build release assets
on:
release:
types: [published]
jobs:
draft:
environment: production
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Write .env to build
env:
DOTENV: '${{ secrets.DOTENV }}'
run: echo "$DOTENV" >> .env
- name: Create public assets
run: mkdir ./server/public ./server/public/audio ./server/public/images
- name: Use Node.js 16.x
uses: actions/setup-node@v2
with:
node-version: 16.x
- name: Install dependencies and build
run: npm run dist
- name: Upload release assets
id: upload-release-asset
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
tag: ${{ github.ref }}
file: ./dist.tar.gz
asset_name: $tag-dist.tar.gz
asset_content_type: application/gzip
overwrite: true

61
.github/workflows/build-deploy.yml vendored Normal file
View file

@ -0,0 +1,61 @@
name: Docker Build and Push
on:
push:
branches:
- main
jobs:
test:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Use Node.js 16.x
uses: actions/setup-node@v2
with:
node-version: 16.x
- name: Install dependencies
run: npm ci
- name: Test build
run: npm run test
build-and-push:
runs-on: ubuntu-latest
needs: test
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Build & push client image
uses: mr-smithers-excellent/docker-build-push@v6
with:
image: c4thebomb/know-it-all-client
registry: docker.io
tags: latest
directory: ./client
dockerfile: ./client/Dockerfile
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Build & push server image
uses: mr-smithers-excellent/docker-build-push@v6
with:
image: c4thebomb/know-it-all-server
registry: docker.io
tags: latest
directory: ./server
dockerfile: ./server/Dockerfile
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
draft:
runs-on: ubuntu-latest
needs: test
steps:
- uses: actions/checkout@v3
- name: Draft release
uses: release-drafter/release-drafter@v5
id: release-draft
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

View file

@ -1,21 +0,0 @@
# This workflow will do a clean installation of node dependencies, cache/restore them, build the source code and run tests across different versions of node
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions
name: Create release draft
on:
push:
branches: [dev]
workflow_dispatch:
jobs:
draft:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Draft release
uses: release-drafter/release-drafter@v5
id: release-draft
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

View file

@ -1,30 +0,0 @@
# This workflow will do a clean installation of node dependencies, cache/restore them, build the source code and run tests across different versions of node
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions
name: Test build
on:
push:
branches: [dev, main]
pull_request:
workflow_dispatch:
jobs:
test:
environment: test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Write ./server/.env to build
env:
DOTENV: '${{ secrets.DOTENV }}'
run: echo "$DOTENV" >> ./server/.env
- name: Use Node.js 16.x
uses: actions/setup-node@v2
with:
node-version: 16.x
- name: Install dependencies
run: npm ci
- name: Test build
run: npm run test

View file

@ -12,4 +12,4 @@ COPY ["./src", "./src"]
EXPOSE 3000/tcp
CMD ["npm", "run" "serve"]
CMD ["npm", "run", "serve"]

View file

@ -1,15 +0,0 @@
# syntax=docker/dockerfile:1
FROM node:16-alpine
WORKDIR /app
COPY ["./package.json", "./package-lock.json*", "./"]
RUN npm install
COPY ["./public", "./public"]
COPY ["./src", "./src"]
EXPOSE 3000/tcp
CMD ["npm", "start"]

View file

@ -45,12 +45,5 @@
"last 1 firefox version",
"last 1 safari version"
]
},
"devDependencies": {
"@testing-library/jest-dom": "^6.4.2",
"@testing-library/react": "^14.2.1",
"axios-mock-adapter": "^1.22.0",
"jest": "^29.7.0",
"sinon": "^17.0.1"
}
}

View file

@ -3,57 +3,32 @@ version: '3.8'
services:
client:
restart: unless-stopped
build:
context: ./client
image: c4thebomb/know-it-all-client
build: ./client
ports:
- 3000:3000
volumes:
- ./client:/app
- client-node:/app/node_modules
networks:
- know-it-all
env_file: .env
- local-network
env_file:
- path: ./.env
required: true
environment:
WATCHPACK_POLLING: true
depends_on:
- server
server:
restart: unless-stopped
build:
context: ./server
image: c4thebomb/know-it-all-server
build: ./server
ports:
- 3000:3001
volumes:
- ./server:/app
- server-node:/app/node_modules
networks:
- know-it-all
env_file: .env
- local-network
env_file:
- path: ./.env
required: true
environment:
DB_CONN_STRING: 'mongodb://mongodb:27017'
CHOKIDAR_USEPOLLING: true
depends_on:
- mysqldb
mysqldb:
restart: unless-stopped
image: mysql:5.7
ports:
- 3306:3306
volumes:
- know-it-all-mysql:/var/lib/mysql
networks:
- know-it-all
environment:
MYSQL_ROOT_PASSWORD: 'passw0rd'
MYSQL_DATABASE: dev
healthcheck:
test: ['CMD', 'mysqladmin', 'ping', '-h', 'localhost']
timeout: 5s
retries: 10
volumes:
know-it-all-mysql:
client-node:
server-node:
networks:
know-it-all: {}
local-network: {}

View file

@ -3,9 +3,8 @@ version: '3.8'
services:
client:
restart: unless-stopped
build:
context: ./client
dockerfile: Dockerfile.dev
build: ./client
image: c4thebomb/know-it-all-client
ports:
- 3000:3000
volumes:
@ -17,10 +16,14 @@ services:
REACT_APP_API_ROOT: 'http://localhost:3001/api'
REACT_APP_DOMAIN_ROOT: 'http://localhost:3000'
WATCHPACK_POLLING: true
env_file:
- path: .env
required: false
command: npm start
server:
restart: unless-stopped
build:
context: ./server/Dockerfile
build: ./server
image: c4thebomb/know-it-all-server
ports:
- 3001:3000
volumes:

7649
package-lock.json generated

File diff suppressed because it is too large Load diff

View file

@ -7,7 +7,7 @@
"start": "concurrently \"npm run start -w client\" \"npm run start -w server\"",
"start:server": "npm start server",
"build": "npm run build -w client",
"test": "npm run test -ws",
"test": "npm run test -w server",
"migrate": "npm run migrate -w server",
"migrate:undo": "npm run migrate:undo -w server"
},