-
Notifications
You must be signed in to change notification settings - Fork 16
96 lines (83 loc) · 2.88 KB
/
feature-minion.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
name: Minion
on:
# Currently triggered by develop workflow, so this trigger is disabled for now until we can fully separate them
# pull_request:
# paths:
# - 'minion/**'
workflow_call:
inputs:
image:
description: 'Name of the image to build'
required: false
type: string
image-tag:
description: 'Tag for the built image'
required: false
type: string
image-registry:
description: 'Docker image registry to tag and push to'
required: false
type: string
env:
IMAGE: ${{ inputs.image || 'lokahi-minion' }}
IMAGE_TAG: ${{ inputs.image-tag || github.sha }}
IMAGE_REGISTRY: ${{ inputs.image-registry || 'ghcr.io' }}
jobs:
build-and-test:
name: Build and test - Minion
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of SonarCloud analysis
- name: Log in to the Container registry
uses: docker/login-action@v2
with:
registry: ${{ env.IMAGE_REGISTRY }}
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Log in to the Container registry
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_LOGIN }}
password: ${{ secrets.DOCKERHUB_PASS }}
- name: Generate Docker metadata
id: docker-metadata
uses: docker/[email protected]
with:
images: |
${{ env.IMAGE_REGISTRY }}/${{ github.repository_owner }}/${{ env.IMAGE }}
tags: |
type=raw,value=${{ env.IMAGE_TAG }}
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
distribution: temurin
java-version: 17
- name: Set up Maven
uses: stCarolas/[email protected]
with:
maven-version: 3.8.2
- name: Cache Maven dependencies
uses: ./.github/actions/maven-cache
with:
cache-key-hash: ${{ hashFiles('minion/**/pom.xml', 'parent-pom/pom.xml', 'shared-lib/**/pom.xml') }}
- name: Cleanup the Maven Cache
uses: ./.github/actions/maven-cache-cleanup-project-artifacts
- name: Build and install prerequisites
uses: ./.github/actions/java-install-prereqs
- name: Build & Sonar Scan
run: |
mvn -B -Dstyle.color=always \
-Pcicd,coverage,run-it \
install \
sonar:sonar \
-Dapplication.docker.image=${{ steps.docker-metadata.outputs.tags }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
working-directory: 'minion'
- name: Push Image
run: docker push ${{ steps.docker-metadata.outputs.tags }}
working-directory: 'minion'