-
Notifications
You must be signed in to change notification settings - Fork 4
95 lines (91 loc) · 3.31 KB
/
workflow-ci-cd.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
name: CI/CD Workflow
run-name: ${{ github.ref_name }} release (${{ github.actor }}) > CI/CD Workflow
on:
release:
types: [created]
jobs:
npm_install_test:
name: Npm - Install & Test
runs-on: ubuntu-latest
services:
elasticsearch:
image: elasticsearch:8.8.0
ports:
- 9200:9200
env:
ES_JAVA_OPTS: -Xms512m -Xmx512m
discovery.type: single-node
xpack.security.enabled: false
volumes:
- elasticsearchdata:/usr/share/elasticsearch/data
- elasticsearchconfig:/usr/share/elasticsearch/config
- elasticsearchlogs:/usr/share/elasticsearch/logs
redis:
image: redis:6.2.11
ports:
- 6379:6379
mongo:
image: mongo:4.0.28
ports:
- 27017:27017
steps:
- name: Checking out repository
uses: actions/checkout@v3
- name: Setting up Node
uses: actions/setup-node@v3
with:
cache: npm
cache-dependency-path: package-lock.json
node-version: 18.20.4
- name: Installing dependencies (dashboard)
run: npm ci
- name: Installing dependencies (client)
run: |
cd client
npm ci
- name: Building (client)
run: npm run build
- name: Testing package (dashboard)
run: npm test
npm_publish:
name: Npm - Publish
needs: npm_install_test
runs-on: ubuntu-latest
steps:
- name: Checking out repository
uses: actions/checkout@v3
- name: Setting up Node + package registry login config
uses: actions/setup-node@v3 # also creates a .npmrc file with registry login config inside the runner, which will use a npm automation token set in $NODE_AUTH_TOKEN env
with:
always-auth: true
cache: npm
cache-dependency-path: package-lock.json
node-version: 18.20.4
registry-url: https://registry.npmjs.org
- name: Package registry login + publish
run: npm publish # will also login before publishing, using the config in .npmrc
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
docker_build_push:
name: Docker - Build & Push
needs: npm_install_test
runs-on: ubuntu-latest
steps:
# - name: Checking out repository
# uses: actions/checkout@v3 # no need to checkout as the build-push-action@v3 action will care about that
# - name: Setting up Docker QEMU
# uses: docker/setup-qemu-action@v2 # add support for more platforms with QEMU (optional): https://github.com/docker/setup-qemu-action
- name: Setting up Docker Buildx
uses: docker/setup-buildx-action@v2 # add support for cache and building multi-platforms images (optional)
- name: Image registry login
uses: docker/login-action@v2
with:
username: ${{ vars.DOCKER_USER }}
password: ${{ secrets.DOCKER_TOKEN }} # safer to use a personal access token instead of a password: https://docs.docker.com/docker-hub/access-tokens/
- name: Building image + pushing image on the registry
uses: docker/build-push-action@v3
with:
cache-from: type=gha
cache-to: type=gha,mode=max
push: true
tags: ${{ vars.DOCKER_IMAGE }}:${{ github.ref_name }}