-
Notifications
You must be signed in to change notification settings - Fork 2
79 lines (75 loc) · 2.58 KB
/
ci.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
name: Lint, test & deploy docker image
on: [push]
concurrency:
group: ci-${{ github.head_ref }}
cancel-in-progress: true
defaults:
run:
shell: bash
jobs:
test:
name: Lint and test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Use Node.js
uses: actions/setup-node@v4
with:
node-version-file: '.nvmrc'
cache: npm
cache-dependency-path: 'package-lock.json'
- name: Set npm access token
run: npm config set //registry.npmjs.org/:_authToken=${{ secrets.NPM_AUTH_TOKEN }}
- name: Install dependencies
run: npm ci
- name: Lint
run: npm run lint
- name: Build app
run: npm run build --if-present
- name: Run tests
run: npm run test
- uses: hadolint/[email protected]
with:
dockerfile: ./Dockerfile
config: ./.hadolint.yaml
docker:
needs: [test]
name: Publish Docker images
runs-on: ubuntu-latest
# run job only for master and tags
if: github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/tags/')
steps:
- uses: actions/checkout@v4
- name: Use Node.js
uses: actions/setup-node@v4
with:
node-version-file: '.nvmrc'
cache: npm
cache-dependency-path: 'package-lock.json'
- name: Set npm access token
run: npm config set //registry.npmjs.org/:_authToken=${{ secrets.NPM_AUTH_TOKEN }}
- name: Install dependencies
run: npm ci
- name: Build app
env:
REACT_APP_DEFAULT_ENV: brubeck
REACT_APP_BASENAME: /network-explorer
REACT_APP_PUBLIC_URL: /network-explorer
REACT_APP_MAPBOX_TOKEN: pk.eyJ1Ijoic3RyZWFtci1uZSIsImEiOiJja3Q0M29zOGkwNmt2MzFwN2d1OWthc2Z4In0.np5n6kX7ea0ig_5TUXdXbw
run: npm run build --if-present
- name: Build Docker image
run: docker build -t $OWNER/$IMAGE_NAME:local --build-arg NPM_AUTH_TOKEN=${{ secrets.NPM_AUTH_TOKEN }} .
- name: Smoke test image
run: .ci_scripts/smoke_test.sh
- uses: docker/[email protected]
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Push streamr/network-explorer:dev
run: .ci_scripts/deploy_docker.sh dev
- name: Push streamr/network-explorer:version
run: .ci_scripts/deploy_docker.sh production ${GITHUB_REF#refs/tags/}
if: startsWith(github.ref, 'refs/tags/') && github.event_name != 'schedule'
env:
OWNER: streamr
IMAGE_NAME: network-explorer