Skip to content

Commit

Permalink
Implemented github actions (#27)
Browse files Browse the repository at this point in the history
Implemented github actions
  • Loading branch information
t9lp authored Dec 30, 2020
1 parent 577f7cd commit 69cb2a3
Show file tree
Hide file tree
Showing 5 changed files with 180 additions and 0 deletions.
36 changes: 36 additions & 0 deletions .github/workflows/pr_test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: PR

on:
pull_request:
branches: [ master ]

jobs:
build:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2

- name: Use Node.js 12
uses: actions/setup-node@v1
with:
node-version: 12.x

- name: Cache Node.js modules
uses: actions/cache@v2
with:
path: ~/.npm
key: ${{ runner.OS }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.OS }}-node-
${{ runner.OS }}-
- run: node --version

- run: npm install

- run: npm run build

- run: npm test
env:
CI: true
77 changes: 77 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
name: Release

on:
push:
tags:
- 'v*.*.*'

jobs:
build:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2

- name: Fetch all history for all tags and branches
run: git fetch --prune --unshallow

- name: Install GitVersion
uses: gittools/actions/gitversion/[email protected]
with:
versionSpec: '5.x'

- name: Use GitVersion
uses: gittools/actions/gitversion/[email protected]
id: gitversion

- name: Use Node.js 12
uses: actions/setup-node@v1
with:
node-version: 12.x

- name: Cache Node.js modules
uses: actions/cache@v2
with:
path: ~/.npm
key: ${{ runner.OS }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.OS }}-node-
${{ runner.OS }}-
- run: node --version

- run: npm install

- run: npm run build

- run: npm test
env:
CI: true

- run: mv ./build ./docker/build

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1

- name: Login to DockerHub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKER_HUB_USER }}
password: ${{ secrets.DOCKER_HUB_TOKEN }}

- name: Build and push
id: docker_build
uses: docker/build-push-action@v2
with:
context: ./docker/
file: ./docker/Dockerfile
builder: ${{ steps.buildx.outputs.name }}
push: true
tags: |
lifescience/med3web:latest
lifescience/med3web:${{ steps.gitversion.outputs.MajorMinorPatch }}
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache

- name: Image digest
run: echo ${{ steps.docker_build.outputs.digest }}
7 changes: 7 additions & 0 deletions GitVersion.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
assembly-versioning-scheme: MajorMinorPatch
mode: ContinuousDeployment
next-version: 1.0.0
branches: {}
ignore:
sha: []
merge-message-formats: {}
8 changes: 8 additions & 0 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
FROM nginx:1.19.3-alpine
RUN apk update && apk upgrade && \
apk add --no-cache curl
WORKDIR /usr/share/nginx/html
COPY ./nginx.conf /etc/nginx/nginx.conf
COPY build .
HEALTHCHECK --interval=10s --timeout=3s \
CMD curl -f http://localhost:4010/user-count/metrics || exit 1
52 changes: 52 additions & 0 deletions docker/nginx.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
worker_processes auto;
error_log /var/log/nginx/error.log warn;
pid /var/run/nginx.pid;
worker_rlimit_nofile 8192;

events {
worker_connections 4096;
}

http {
include /etc/nginx/mime.types;
default_type text/html;

log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';

access_log off;
index index.html;

sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 15;
reset_timedout_connection on;

open_file_cache max=200000 inactive=20s;
open_file_cache_valid 30s;
open_file_cache_min_uses 2;
open_file_cache_errors on;

server {
listen 80;
listen [::]:80;
server_name _;

gzip off;

location / {
root /usr/share/nginx/html;
index index.html index.htm;
try_files $uri $uri/ /index.html =404;
add_header Cache-Control "max-age=3600,private";
}
location ~* \.(?:jpg|jpeg|gif|png|ttf|svg|ico)$ {
root /usr/share/nginx/html;
log_not_found off;
expires max;
add_header Cache-Control "max-age=86400,private";
}
}
}

0 comments on commit 69cb2a3

Please sign in to comment.