This repository has been archived by the owner on Feb 13, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 49
104 lines (84 loc) · 3.09 KB
/
build.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
name: CI/CD
on:
pull_request:
branches:
- main
push:
branches:
- main
tags:
- '**'
release:
types:
- published
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
# needed for the license header check
fetch-depth: 0
# Setup Phase
- name: Setup node and install deps
uses: actions/setup-node@v3
with:
node-version: '16'
check-latest: true
- run: npm --prefix frontend ci --legacy-peer-deps
- name: Setup Java
uses: actions/setup-java@v3
with:
distribution: 'temurin'
java-version: '17'
check-latest: true
cache: 'maven'
- name: Prepare docker tags for bpa image
id: preparetags
uses: docker/metadata-action@v4
with:
images: ghcr.io/hyperledger-labs/business-partner-agent-new
tags: |
type=ref,event=tag,priority=900
type=sha,priority=800
type=edge,branch=main,priority=700
# Test Phase
- name: Test frontend license headers
run: npm --prefix frontend run license-file-headers-check
- name: Test frontend dependency licenses
## TODO are there any frontend tests?
run: npm --prefix frontend run license-check
- name: Test with Maven
run: mvn -f backend/pom.xml test spotbugs:check pmd:check pmd:cpd-check license:check dependency-check:check -Ddependency-check.skip=false
# Build Phase
- name: Build frontend
run: npm --prefix frontend run build
- name: Copy dist folder to backend
run: cp -r ./frontend/dist ./backend/business-partner-agent/src/main/resources/public
- name: Build backend
run: mvn -f backend/pom.xml clean package -Drevision=${{ fromJSON(steps.preparetags.outputs.json).labels['org.opencontainers.image.version'] }} -DskipTests=true -Dspotbugs.skip=true -Dpmd.skip=true -Dlicense.skip=true
# Docker Phase (triggered only on main or tag)
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
if: ${{ github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/') }}
with:
platforms: linux/amd64,linux/arm64
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
if: ${{ github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/') }}
- name: Login to GitHub Container Registry
uses: docker/login-action@v2
if: ${{ github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/') }}
with:
registry: ghcr.io
username: ${{ github.repository_owner}}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push container
uses: docker/build-push-action@v4
if: ${{ github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/') }}
with:
context: .
platforms: linux/amd64,linux/arm64
push: true
file: Dockerfile.run
tags: ${{ steps.preparetags.outputs.tags }}