forked from bcgov/nr-bcws-wfnews
-
Notifications
You must be signed in to change notification settings - Fork 0
134 lines (112 loc) · 4.15 KB
/
mvn-client.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
# This is a basic workflow to help you get started with Actions
name: Build Client
env:
IMAGE_NAME: ${{ github.repository }}-client
NPMRC: ${{ secrets.NPMRC }}
# Controls when the workflow will run
on:
workflow_call:
inputs:
ENVIRONMENT:
required: true
type: string
IS_HOTFIX:
required: false
type: string
default: 'false'
BRANCH:
required: false
type: string
TAG:
required: false
type: string
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
build:
runs-on: ubuntu-latest
environment:
name: ${{ inputs.ENVIRONMENT }}
steps:
- uses: actions/checkout@v3
if: ${{ inputs.IS_HOTFIX != 'true' }}
- uses: actions/checkout@v3
if: ${{ inputs.IS_HOTFIX == 'true' }}
with:
ref: ${{ inputs.BRANCH }}
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'adopt'
- name: Add .npmrc file
run: echo -e $NPMRC > ~/.npmrc
- name: Inject GitHub Build Number and Display Directory
run: |
echo "Current working directory:"
pwd
echo "export const BUILD_NUMBER = '${{ github.run_number }}';" > client/wfnews-war/src/main/angular/src/environments/build-info.ts
echo "Contents: "
ls -lah
- name: Build with Maven
run: |
export MAVEN_OPTS="-Xmx3072m -XX:MaxMetaspaceSize=512m"
export NODE_OPTIONS="--max-old-space-size=4096"
mvn --settings client/mvn_settings/settings.xml --batch-mode --update-snapshots -f client/pom.xml -Drepo.login=${{ secrets.IDIR_AS_EMAIL }} -Drepo.password=${{ secrets.IDIR_PASSWORD }} -DskipTests package
- name: Copy files to neccessary folders
run: mkdir staging && cp client/wfnews-war/target/*.war staging
- uses: actions/upload-artifact@v3
with:
name: Package-client
path: staging
- name: Cache local Maven repository
uses: actions/cache@v2
with:
path: staging
key: ${{ runner.os }}-maven-${{ hashFiles('**war.xml') }}
restore-keys: |
${{ runner.os }}-maven-
docker:
needs: build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
if: ${{ inputs.IS_HOTFIX != 'true' }}
- uses: actions/checkout@v3
if: ${{ inputs.IS_HOTFIX == 'true' }}
with:
ref: ${{ inputs.BRANCH }}
- name: download artifact
uses: actions/download-artifact@v3
with:
name: Package-client
path: .
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Login to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ${{ vars.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract metadata (tags, labels) for Docker
if: ${{ github.event.pull_request.number > 0 || inputs.IS_HOTFIX == 'true' }}
id: meta_pr
uses: docker/metadata-action@98669ae865ea3cffbcbaa878cf57c20bbf1c6c38
with:
images: ${{ vars.REGISTRY}}/${{ env.IMAGE_NAME }}${{ inputs.IS_HOTFIX == 'true' && '-hotfix' || '' }}
tags: |
type=schedule
type=raw,value=${{ github.base_ref }}
type=ref,event=tag
type=raw,value=${{ inputs.IS_HOTFIX == 'true' && format('hotfix-{0}', inputs.BRANCH) || format( 'pr-{0}', github.event.pull_request.number) }}
- name: Build and push Docker image (with PR)
if: ${{ github.event.pull_request.number > 0 || inputs.IS_HOTFIX == 'true' }}
uses: docker/build-push-action@ad44023a93711e3deb337508980b4b5e9bcdc5dc
with:
context: .
file: Dockerfile_client
push: true
tags: ${{ steps.meta_pr.outputs.tags }}
labels: ${{ steps.meta_pr.outputs.labels }}