-
Notifications
You must be signed in to change notification settings - Fork 15
122 lines (102 loc) · 4 KB
/
mvn-server.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
name: Build Server
env:
IMAGE_NAME: "${{ github.repository }}-${{inputs.PROJECT_NAME}}"
on:
workflow_call:
inputs:
ENVIRONMENT:
required: true
type: string
PROJECT_NAME:
type: string
description: 'Name of project, as given to the subfolder of /server to build'
required: true
IS_HOTFIX:
required: false
type: string
default: 'false'
BRANCH:
required: false
type: string
TAG:
required: false
type: string
jobs:
build:
runs-on: ubuntu-latest
environment:
name: ${{ inputs.ENVIRONMENT }}
steps:
- uses: actions/checkout@v3
if: ${{ github.event.inputs.IS_HOTFIX != 'true' }}
- uses: actions/checkout@v3
if: ${{ github.event.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: Build with Maven
run: mvn --settings server/${{ inputs.PROJECT_NAME }}/mvn_settings/settings.xml --batch-mode --update-snapshots -f server/${{ inputs.PROJECT_NAME }}/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 server/${{ inputs.PROJECT_NAME }}/${{ inputs.PROJECT_NAME }}-rest-endpoints/target/*.war staging
- uses: actions/upload-artifact@v4
with:
name: ${{ inputs.PROJECT_NAME }}-package
path: staging
- name: Cache local Maven repository
uses: actions/cache@v2
with:
path: staging
key: ${{ inputs.PROJECT_NAME }}-maven-${{ hashFiles('**war.xml') }}
restore-keys: |
${{ inputs.PROJECT_NAME }}-maven-
docker:
needs: build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
if: ${{ github.event.inputs.IS_HOTFIX != 'true' }}
- uses: actions/checkout@v3
if: ${{ github.event.inputs.IS_HOTFIX == 'true' }}
with:
ref: ${{ inputs.BRANCH }}
- name: download artifact
uses: actions/download-artifact@v4
with:
name: ${{ inputs.PROJECT_NAME }}-package
path: .
- name: Update image name if PR number present
if: ${{ github.event.pull_request.number > 0 || inputs.IS_HOTFIX == 'true' }}
run: echo "IMAGE_NAME = ${{env.IMAGE_NAME}}-${{ inputs.IS_HOTFIX == 'true' && 'hotfix' || github.event.pull_request.number }}" >> $GITHUB_ENV
- 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 (with PR)
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 }}
tags: |
type=schedule
type=raw,value=${{ github.base_ref }}
type=ref,event=tag
type=raw,value=${{ inputs.IS_HOTFIX && 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: .
push: true
tags: ${{ steps.meta_pr.outputs.tags }}
labels: ${{ steps.meta_pr.outputs.labels }}