Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PI-2770 use jib in pipeline #816

Merged
merged 2 commits into from
Feb 28, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 51 additions & 0 deletions .github/workflows/jib-build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
name: Build & push docker image and deploy to environment

on:
workflow_call:

outputs:
app_version:
description: The version of the app as generated by create_app_version
value: ${{ jobs.docker_build.outputs.version }}

permissions:
contents: read
packages: write

jobs:
docker_build:
name: Build docker image
runs-on: ubuntu-latest
outputs:
version: ${{ steps.app_version.outputs.version }}
steps:
- id: app_version
name: Application version creators
uses: ministryofjustice/hmpps-github-actions/.github/actions/build-test-and-deploy/create_app_version@v2 # WORKFLOW_VERSION

- uses: actions/checkout@v4
- name: refresh cache
id: initial-cache
uses: actions/cache@v4
env:
cache-name: kotlin-cache
with:
path: |
- gradle-{{ checksum "build.gradle.kts" }}
- gradle-
key: ${{ runner.os }}-gradle-${{ env.cache-name }}-${{ hashFiles('build.gradle.kts') }}

- uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: '21'
cache: 'gradle'
cache-dependency-path: |
*.gradle*
**/gradle-wrapper.properties
- 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}"
env:
GITHUB_USERNAME: ${{ github.actor }}
GITHUB_PASSWORD: ${{ github.token }}
BUILD_NUMBER: ${{ steps.app_version.outputs.version }}
IMAGE_NAME: "ghcr.io/ministryofjustice/probation-offender-search"
24 changes: 8 additions & 16 deletions .github/workflows/pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,24 +35,16 @@ jobs:
name: Validate the kotlin
uses: ./.github/workflows/kotlin_integration_tests.yml
secrets: inherit
build:
name: Build docker image from hmpps-github-actions
if: github.ref == 'refs/heads/main'
uses: ministryofjustice/hmpps-github-actions/.github/workflows/docker_build.yml@v2 # WORKFLOW_VERSION
needs:
- kotlin_validate
with:
docker_registry: 'ghcr.io'
registry_org: 'ministryofjustice'
additional_docker_tag: ""
push: ${{ inputs.push || true }}
docker_multiplatform: false
additional_docker_build_args: ""
docker_build:
if: ${{ github.ref == 'refs/heads/main' || inputs.push }}
name: Push image
uses: ./.github/workflows/jib-build.yml
needs: kotlin_validate
deploy_dev:
name: Deploy to the dev environment
if: github.ref == 'refs/heads/main'
needs:
- build
- docker_build
- helm_lint
uses: ministryofjustice/hmpps-github-actions/.github/workflows/deploy_env.yml@v2 # WORKFLOW_VERSION
secrets: inherit
Expand All @@ -62,7 +54,7 @@ jobs:
deploy_preprod:
name: Deploy to the preprod environment
needs:
- build
- docker_build
- helm_lint
uses: ministryofjustice/hmpps-github-actions/.github/workflows/deploy_env.yml@v2 # WORKFLOW_VERSION
secrets: inherit
Expand All @@ -72,7 +64,7 @@ jobs:
deploy_prod:
name: Deploy to the prod environment
needs:
- build
- docker_build
- helm_lint
- deploy_dev
- deploy_preprod
Expand Down
Loading