forked from DependencyTrack/frontend
-
Notifications
You must be signed in to change notification settings - Fork 0
54 lines (48 loc) · 2.09 KB
/
nodejs.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
name: Node CI
on: [push, pull_request, workflow_dispatch]
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [10.x, 12.x, 14.x]
env:
DOCKER_REPO: dependencytrack/frontend
DOCKER_TAG: snapshot
steps:
- uses: actions/checkout@v1
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}
- name: npm install, build, and test
run: |
npm ci
npm run build --if-present
npm test
env:
CI: true
- name: Building Docker container
run: |
docker build -f docker/Dockerfile -t $DOCKER_REPO:$DOCKER_TAG .
- name: Installing Docker analysis tools
run: |
sudo apt install jq
export DOCKLE_VERSION=$(curl --silent "https://api.github.com/repos/goodwithtech/dockle/releases/latest" | grep '"tag_name":' | sed -E 's/.*"v([^"]+)".*/\1/')
wget -O ~/dockle.tar.gz https://github.com/goodwithtech/dockle/releases/download/v${DOCKLE_VERSION}/dockle_${DOCKLE_VERSION}_Linux-64bit.tar.gz
tar zxvf ~/dockle.tar.gz -C ~/
export TRIVY_VERSION=$(curl --silent "https://api.github.com/repos/aquasecurity/trivy/releases/latest" | grep '"tag_name":' | sed -E 's/.*"v([^"]+)".*/\1/')
wget -O ~/trivy.tar.gz https://github.com/aquasecurity/trivy/releases/download/v${TRIVY_VERSION}/trivy_${TRIVY_VERSION}_Linux-64bit.tar.gz
tar zxvf ~/trivy.tar.gz -C ~/
- name: Analyzing Docker container
run: |
~/dockle $DOCKER_REPO:$DOCKER_TAG
~/trivy --exit-code 0 --quiet --auto-refresh $DOCKER_REPO:$DOCKER_TAG
- name: Publishing container to Docker Hub
if: ((github.event_name == 'push' && github.ref == 'refs/heads/master') || github.event_name == 'workflow_dispatch') && startsWith(matrix.node-version, '12.')
env:
HUB_USERNAME: ${{ secrets.HUB_USERNAME }}
HUB_ACCESS_TOKEN: ${{ secrets.HUB_ACCESS_TOKEN }}
run: |
docker login -u "$HUB_USERNAME" -p "$HUB_ACCESS_TOKEN"
docker push "$DOCKER_REPO:$DOCKER_TAG"