Created CI/CD workflow
This commit is contained in:
parent
fb43f05d8a
commit
469204a30f
11 changed files with 9704 additions and 13663 deletions
38
.github/workflows/build-assets.yml
vendored
38
.github/workflows/build-assets.yml
vendored
|
|
@ -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
61
.github/workflows/build-deploy.yml
vendored
Normal 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 }}
|
||||||
21
.github/workflows/draft-release.yml
vendored
21
.github/workflows/draft-release.yml
vendored
|
|
@ -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 }}
|
|
||||||
30
.github/workflows/test-build.yml
vendored
30
.github/workflows/test-build.yml
vendored
|
|
@ -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
|
|
||||||
|
|
@ -12,4 +12,4 @@ COPY ["./src", "./src"]
|
||||||
|
|
||||||
EXPOSE 3000/tcp
|
EXPOSE 3000/tcp
|
||||||
|
|
||||||
CMD ["npm", "run" "serve"]
|
CMD ["npm", "run", "serve"]
|
||||||
|
|
@ -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"]
|
|
||||||
|
|
@ -45,12 +45,5 @@
|
||||||
"last 1 firefox version",
|
"last 1 firefox version",
|
||||||
"last 1 safari 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"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -3,57 +3,32 @@ version: '3.8'
|
||||||
services:
|
services:
|
||||||
client:
|
client:
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
build:
|
image: c4thebomb/know-it-all-client
|
||||||
context: ./client
|
build: ./client
|
||||||
ports:
|
ports:
|
||||||
- 3000:3000
|
- 3000:3000
|
||||||
volumes:
|
|
||||||
- ./client:/app
|
|
||||||
- client-node:/app/node_modules
|
|
||||||
networks:
|
networks:
|
||||||
- know-it-all
|
- local-network
|
||||||
env_file: .env
|
env_file:
|
||||||
|
- path: ./.env
|
||||||
|
required: true
|
||||||
environment:
|
environment:
|
||||||
WATCHPACK_POLLING: true
|
WATCHPACK_POLLING: true
|
||||||
depends_on:
|
depends_on:
|
||||||
- server
|
- server
|
||||||
server:
|
server:
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
build:
|
image: c4thebomb/know-it-all-server
|
||||||
context: ./server
|
build: ./server
|
||||||
ports:
|
ports:
|
||||||
- 3000:3001
|
- 3000:3001
|
||||||
volumes:
|
|
||||||
- ./server:/app
|
|
||||||
- server-node:/app/node_modules
|
|
||||||
networks:
|
networks:
|
||||||
- know-it-all
|
- local-network
|
||||||
env_file: .env
|
env_file:
|
||||||
|
- path: ./.env
|
||||||
|
required: true
|
||||||
environment:
|
environment:
|
||||||
DB_CONN_STRING: 'mongodb://mongodb:27017'
|
DB_CONN_STRING: 'mongodb://mongodb:27017'
|
||||||
CHOKIDAR_USEPOLLING: true
|
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:
|
networks:
|
||||||
know-it-all: {}
|
local-network: {}
|
||||||
|
|
|
||||||
|
|
@ -3,9 +3,8 @@ version: '3.8'
|
||||||
services:
|
services:
|
||||||
client:
|
client:
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
build:
|
build: ./client
|
||||||
context: ./client
|
image: c4thebomb/know-it-all-client
|
||||||
dockerfile: Dockerfile.dev
|
|
||||||
ports:
|
ports:
|
||||||
- 3000:3000
|
- 3000:3000
|
||||||
volumes:
|
volumes:
|
||||||
|
|
@ -17,10 +16,14 @@ services:
|
||||||
REACT_APP_API_ROOT: 'http://localhost:3001/api'
|
REACT_APP_API_ROOT: 'http://localhost:3001/api'
|
||||||
REACT_APP_DOMAIN_ROOT: 'http://localhost:3000'
|
REACT_APP_DOMAIN_ROOT: 'http://localhost:3000'
|
||||||
WATCHPACK_POLLING: true
|
WATCHPACK_POLLING: true
|
||||||
|
env_file:
|
||||||
|
- path: .env
|
||||||
|
required: false
|
||||||
|
command: npm start
|
||||||
server:
|
server:
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
build:
|
build: ./server
|
||||||
context: ./server/Dockerfile
|
image: c4thebomb/know-it-all-server
|
||||||
ports:
|
ports:
|
||||||
- 3001:3000
|
- 3001:3000
|
||||||
volumes:
|
volumes:
|
||||||
|
|
|
||||||
7649
package-lock.json
generated
7649
package-lock.json
generated
File diff suppressed because it is too large
Load diff
|
|
@ -7,7 +7,7 @@
|
||||||
"start": "concurrently \"npm run start -w client\" \"npm run start -w server\"",
|
"start": "concurrently \"npm run start -w client\" \"npm run start -w server\"",
|
||||||
"start:server": "npm start server",
|
"start:server": "npm start server",
|
||||||
"build": "npm run build -w client",
|
"build": "npm run build -w client",
|
||||||
"test": "npm run test -ws",
|
"test": "npm run test -w server",
|
||||||
"migrate": "npm run migrate -w server",
|
"migrate": "npm run migrate -w server",
|
||||||
"migrate:undo": "npm run migrate:undo -w server"
|
"migrate:undo": "npm run migrate:undo -w server"
|
||||||
},
|
},
|
||||||
|
|
|
||||||
Reference in a new issue