Skip to content

Commit 7f02eb1

Browse files
PI-2770 use jib in pipeline (#816)
* PI-2770 use jib in gha
1 parent 61ba489 commit 7f02eb1

File tree

2 files changed

+59
-16
lines changed

2 files changed

+59
-16
lines changed

.github/workflows/jib-build.yml

+51
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
name: Build & push docker image and deploy to environment
2+
3+
on:
4+
workflow_call:
5+
6+
outputs:
7+
app_version:
8+
description: The version of the app as generated by create_app_version
9+
value: ${{ jobs.docker_build.outputs.version }}
10+
11+
permissions:
12+
contents: read
13+
packages: write
14+
15+
jobs:
16+
docker_build:
17+
name: Build docker image
18+
runs-on: ubuntu-latest
19+
outputs:
20+
version: ${{ steps.app_version.outputs.version }}
21+
steps:
22+
- id: app_version
23+
name: Application version creators
24+
uses: ministryofjustice/hmpps-github-actions/.github/actions/build-test-and-deploy/create_app_version@v2 # WORKFLOW_VERSION
25+
26+
- uses: actions/checkout@v4
27+
- name: refresh cache
28+
id: initial-cache
29+
uses: actions/cache@v4
30+
env:
31+
cache-name: kotlin-cache
32+
with:
33+
path: |
34+
- gradle-{{ checksum "build.gradle.kts" }}
35+
- gradle-
36+
key: ${{ runner.os }}-gradle-${{ env.cache-name }}-${{ hashFiles('build.gradle.kts') }}
37+
38+
- uses: actions/setup-java@v4
39+
with:
40+
distribution: 'temurin'
41+
java-version: '21'
42+
cache: 'gradle'
43+
cache-dependency-path: |
44+
*.gradle*
45+
**/gradle-wrapper.properties
46+
- run: ./gradlew jib --image="${IMAGE_NAME}:${BUILD_NUMBER}" -Djib.to.auth.username=${GITHUB_USERNAME} -Djib.to.auth.password=${GITHUB_PASSWORD} -Djib.to.tags=latest -Djib.container.environment=BUILD_NUMBER="${BUILD_NUMBER}"
47+
env:
48+
GITHUB_USERNAME: ${{ github.actor }}
49+
GITHUB_PASSWORD: ${{ github.token }}
50+
BUILD_NUMBER: ${{ steps.app_version.outputs.version }}
51+
IMAGE_NAME: "ghcr.io/ministryofjustice/probation-offender-search"

.github/workflows/pipeline.yml

+8-16
Original file line numberDiff line numberDiff line change
@@ -35,24 +35,16 @@ jobs:
3535
name: Validate the kotlin
3636
uses: ./.github/workflows/kotlin_integration_tests.yml
3737
secrets: inherit
38-
build:
39-
name: Build docker image from hmpps-github-actions
40-
if: github.ref == 'refs/heads/main'
41-
uses: ministryofjustice/hmpps-github-actions/.github/workflows/docker_build.yml@v2 # WORKFLOW_VERSION
42-
needs:
43-
- kotlin_validate
44-
with:
45-
docker_registry: 'ghcr.io'
46-
registry_org: 'ministryofjustice'
47-
additional_docker_tag: ""
48-
push: ${{ inputs.push || true }}
49-
docker_multiplatform: false
50-
additional_docker_build_args: ""
38+
docker_build:
39+
if: ${{ github.ref == 'refs/heads/main' || inputs.push }}
40+
name: Push image
41+
uses: ./.github/workflows/jib-build.yml
42+
needs: kotlin_validate
5143
deploy_dev:
5244
name: Deploy to the dev environment
5345
if: github.ref == 'refs/heads/main'
5446
needs:
55-
- build
47+
- docker_build
5648
- helm_lint
5749
uses: ministryofjustice/hmpps-github-actions/.github/workflows/deploy_env.yml@v2 # WORKFLOW_VERSION
5850
secrets: inherit
@@ -62,7 +54,7 @@ jobs:
6254
deploy_preprod:
6355
name: Deploy to the preprod environment
6456
needs:
65-
- build
57+
- docker_build
6658
- helm_lint
6759
uses: ministryofjustice/hmpps-github-actions/.github/workflows/deploy_env.yml@v2 # WORKFLOW_VERSION
6860
secrets: inherit
@@ -72,7 +64,7 @@ jobs:
7264
deploy_prod:
7365
name: Deploy to the prod environment
7466
needs:
75-
- build
67+
- docker_build
7668
- helm_lint
7769
- deploy_dev
7870
- deploy_preprod

0 commit comments

Comments
 (0)