generated from ministryofjustice/template-repository
-
Notifications
You must be signed in to change notification settings - Fork 0
153 lines (140 loc) · 4.87 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
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
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
name: Build
on:
workflow_call:
inputs:
push:
type: boolean
default: false
force-deploy:
type: boolean
default: false
outputs:
version:
value: ${{ jobs.build-gradle.outputs.version }}
workflow_dispatch:
inputs:
push:
description: Push images
type: boolean
default: false
force-deploy:
description: Force re-tagging and deployment of images
type: boolean
default: false
env:
push: ${{ !(github.event_name == 'push' && github.ref_name != 'main') && inputs.push }}
jobs:
build-gradle:
name: Gradle build
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
project:
- approved-premises-and-delius
- approved-premises-and-oasys
- court-case-and-delius
- create-and-vary-a-licence-and-delius
- custody-key-dates-and-delius
- domain-events-and-delius
- effective-proposal-framework-and-delius
- external-api-and-delius
- make-recall-decisions-and-delius
- manage-pom-cases-and-delius
- offender-events-and-delius
- pathfinder-and-delius
- pre-sentence-reports-to-delius
- prison-case-notes-to-probation
- prison-custody-status-to-delius
- refer-and-monitor-and-delius
- risk-assessment-scores-to-delius
- sentence-plan-and-delius
- sentence-plan-and-oasys
- soc-and-delius
- tier-to-delius
- unpaid-work-and-delius
- workforce-allocations-to-delius
- manage-offences-and-delius
- resettlement-passport-and-delius
- prison-education-and-delius
- opd-and-delius
- hmpps-auth-and-delius
- dps-and-delius
- arns-and-delius
- cas3-and-delius
- hdc-licences-and-delius
- prisoner-profile-and-delius
# ^ add new projects here
# GitHub Actions doesn't support dynamic choices, we must add each project here to enable manual deployments
# See https://github.com/community/community/discussions/11795
outputs:
version: ${{ steps.version.outputs.version }}
changes: ${{ steps.check-changes.outputs.changes }}
steps:
- uses: actions/checkout@v4
- uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'temurin'
- uses: gradle/gradle-build-action@v2
- name: Set version
id: version
run: |
version=$(date '+%Y-%m-%d').${{ github.run_number }}.$(echo ${{ github.sha }} | cut -c1-7)
echo "ORG_GRADLE_PROJECT_version=$version" | tee -a "$GITHUB_ENV"
echo "version=$version" | tee -a "$GITHUB_OUTPUT"
- name: Build and test
run: ./gradlew ${{ matrix.project }}:check
env:
SPRING_PROFILES_ACTIVE: oracle
- name: Push images
if: env.push == 'true'
run: ./gradlew ${{ matrix.project }}:jib
env:
GITHUB_USERNAME: ${{ github.actor }}
GITHUB_PASSWORD: ${{ github.token }}
FORCE_DEPLOY: ${{ inputs.force-deploy }}
- name: Check changes
id: check-changes
run: echo "changes=$(find changed -mindepth 1 -maxdepth 1 -printf "%f\n" | jq --raw-input . | jq --slurp --compact-output .)" | tee -a "$GITHUB_OUTPUT"
- name: Output changes
uses: cloudposse/github-action-matrix-outputs-write@928e2a2d3d6ae4eb94010827489805c17c81181f # v0.4.2
with:
matrix-step-name: output-changes
matrix-key: ${{ matrix.project }}
outputs: ${{ steps.check-changes.outputs.changes }}
- uses: actions/upload-artifact@v3
with:
name: test-results
path: |
**/build/jacoco
**/build/reports/jacoco/**/*.xml
**/build/test-results
build-docker:
name: Docker build
runs-on: ubuntu-latest
strategy:
matrix:
project:
- person-search-index-from-delius
steps:
- uses: actions/checkout@v4
- name: Set version
id: version
run: |
version=$(date '+%Y-%m-%d').${{ github.run_number }}.$(echo ${{ github.sha }} | cut -c1-7)
echo "version=$version" | tee -a "$GITHUB_OUTPUT"
- name: Build Docker images
uses: ./.github/actions/docker-build
id: build
with:
project: ${{ matrix.project }}
push: ${{ env.push }}
version: ${{ steps.version.outputs.version }}
force-deploy: ${{ inputs.force-deploy }}
- name: Output changes
uses: cloudposse/github-action-matrix-outputs-write@928e2a2d3d6ae4eb94010827489805c17c81181f # v0.4.2
with:
matrix-step-name: output-changes
matrix-key: ${{ matrix.project }}
outputs: ${{ steps.build.outputs.changes }}