-
Notifications
You must be signed in to change notification settings - Fork 10
163 lines (159 loc) · 4.88 KB
/
node.js.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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
# This workflow will do a clean install 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: CI Test and Publish Workflow
on:
workflow_dispatch:
push:
branches: [main]
pull_request:
branches: [main]
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [18.x]
steps:
- uses: actions/checkout@v3
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/[email protected]
with:
node-version: ${{ matrix.node-version }}
cache: "yarn"
- name: Install dependencies
run: yarn --frozen-lockfile
- run: yarn build
- name: Upload production artifacts
uses: actions/[email protected]
with:
name: Static Build folder
path: |
./build
lint:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [18.x]
steps:
- uses: actions/checkout@v3
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/[email protected]
with:
node-version: ${{ matrix.node-version }}
cache: "yarn"
- name: Install dependencies
run: yarn --frozen-lockfile
- run: yarn lint
security:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [18.x]
steps:
- uses: actions/checkout@v3
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/[email protected]
with:
node-version: ${{ matrix.node-version }}
cache: "yarn"
- name: Running audit check
run: yarn audit --groups dependencies
- name: docker-security
uses: instrumenta/conftest-action@master
with:
files: Dockerfile
policy: dockerfile-security.rego
unit-test:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [18.x]
steps:
- uses: actions/checkout@v3
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/[email protected]
with:
node-version: ${{ matrix.node-version }}
cache: "yarn"
- name: Install dependencies
run: yarn --frozen-lockfile
- name: Running unit tests
run: yarn test:coverage
- run: yarn build
- name: Upload test artifacts
uses: actions/[email protected]
with:
name: coverage
path: |
./coverage
publish:
runs-on: ubuntu-latest
if: github.event_name != 'pull_request'
permissions:
contents: read
packages: write
needs:
- build
- security
- lint
- unit-test
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Log in to the Github Container registry
uses: docker/login-action@v1
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract branch name
shell: bash
run: echo "branch=${GITHUB_REF##*/}" >> $GITHUB_OUTPUT
id: extract_branch
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v3
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
labels: |
maintainer=Team Digitale
org.opencontainers.image.source.branch=${{ steps.extract_branch.outputs.branch }}
tags: |
type=raw,value={{date 'YYYYMMDD'}}-${{github.run_number}}-{{sha}}
type=raw, value=latest
- name: Build and push Docker image
uses: docker/build-push-action@v2
with:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
deploy:
runs-on: ubuntu-latest
if: github.event_name != 'pull_request'
permissions:
contents: read
packages: write
needs:
- publish
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: build image
id: extractImage
run: |
IMAGE="$REGISTRY/$IMAGE_NAME"
TAG="$(date +'%Y%m%d')-${{github.run_number}}-$(git rev-parse --short HEAD)"
echo "imageName=${IMAGE}:${TAG}" >> $GITHUB_OUTPUT
- uses: convictional/[email protected]
with:
owner: teamdigitale
repo: dati-semantic-kubernetes
github_token: ${{ secrets.PERSONAL_ACCESS_TOKEN }}
workflow_file_name: update-config.yaml
ref: dev
wait_interval: 20
inputs: '{"serviceName": "dati-semantic-frontend", "imageWithNewTag": "${{ steps.extractImage.outputs.imageName }}"}'