Skip to content

Commit

Permalink
HEAT-313 - implement Github workflows for test -> build -> deploy (#245)
Browse files Browse the repository at this point in the history
  • Loading branch information
james-jdgtl authored Nov 12, 2024
1 parent 3924337 commit f0e66c3
Show file tree
Hide file tree
Showing 4 changed files with 122 additions and 105 deletions.
96 changes: 0 additions & 96 deletions .circleci/config.yml

This file was deleted.

109 changes: 109 additions & 0 deletions .github/workflows/pipeline.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
name: Pipeline [test -> build -> deploy]

on:
push:
branches:
- '**'

workflow_dispatch:
inputs:
environment:
description: Environment
type: choice
required: true
options:
- dev
- preprod
- staging
- production
default: 'dev'
docker_registry:
description: Docker registry
required: true
default: 'ghcr.io'
type: choice
options:
- 'ghcr.io'
- 'quay.io'
registry_org:
description: Docker registry organisation
required: true
default: 'ministryofjustice'
type: choice
options:
- 'ministryofjustice'
- 'hmpps'
additional_docker_tag:
description: Additional docker tag that can be used to specify stable tags
required: false
default: ''
type: string
push:
description: Push docker image to registry flag
required: true
default: true
type: boolean
docker_multiplatform:
description: docker multiplatform build or not
required: true
default: true
type: boolean

permissions:
contents: read
packages: write

jobs:
helm_lint:
name: helm lint
uses: ministryofjustice/hmpps-github-actions/.github/workflows/test_helm_lint.yml@v1 # WORKFLOW VERSION
secrets: inherit
with:
environment: ${{ inputs.environment || 'dev' }}
kotlin_validate:
name: Validate the kotlin
uses: ministryofjustice/hmpps-github-actions/.github/workflows/kotlin_validate.yml@v1 # WORKFLOW_VERSION
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@v1 # WORKFLOW_VERSION
needs:
- kotlin_validate
with:
docker_registry: ${{ inputs.docker_registry || 'ghcr.io' }}
registry_org: ${{ inputs.registry_org || 'ministryofjustice' }}
additional_docker_tag: ${{ inputs.additional_docker_tag }}
push: ${{ inputs.push || true }}
docker_multiplatform: ${{ inputs.docker_multiplatform || true }}
deploy_dev:
name: Deploy to dev environment
needs:
- build
- helm_lint
uses: ministryofjustice/hmpps-github-actions/.github/workflows/deploy_env.yml@v1 # WORKFLOW_VERSION
secrets: inherit
with:
environment: 'dev'
app_version: '${{ needs.build.outputs.app_version }}'

# deploy_preprod:
# name: Deploy to pre-production environment
# needs:
# - build
# - deploy_dev
# uses: ministryofjustice/hmpps-github-actions/.github/workflows/deploy_env.yml@v1 # WORKFLOW_VERSION
# secrets: inherit
# with:
# environment: 'preprod'
# app_version: '${{ needs.build.outputs.app_version }}'
# deploy_prod:
# name: Deploy to production environment
# needs:
# - build
# - deploy_preprod
# uses: ministryofjustice/hmpps-github-actions/.github/workflows/deploy_env.yml@v1 # WORKFLOW_VERSION
# secrets: inherit
# with:
# environment: 'prod'
# app_version: '${{ needs.build.outputs.app_version }}'
17 changes: 10 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
# hmpps-template-kotlin

[![repo standards badge](https://img.shields.io/badge/endpoint.svg?&style=flat&logo=github&url=https%3A%2F%2Foperations-engineering-reports.cloud-platform.service.justice.gov.uk%2Fapi%2Fv1%2Fcompliant_public_repositories%2Fhmpps-template-kotlin)](https://operations-engineering-reports.cloud-platform.service.justice.gov.uk/public-report/hmpps-template-kotlin "Link to report")
[![CircleCI](https://circleci.com/gh/ministryofjustice/hmpps-template-kotlin/tree/main.svg?style=svg)](https://circleci.com/gh/ministryofjustice/hmpps-template-kotlin)
[![Docker Repository on Quay](https://img.shields.io/badge/quay.io-repository-2496ED.svg?logo=docker)](https://quay.io/repository/hmpps/hmpps-template-kotlin)
[![Docker Repository on ghcr](https://img.shields.io/badge/ghcr.io-repository-2496ED.svg?logo=docker)](https://ghcr.io/ministryofjustice/hmpps-template-kotlin)
[![API docs](https://img.shields.io/badge/API_docs_-view-85EA2D.svg?logo=swagger)](https://hmpps-template-kotlin-dev.hmpps.service.justice.gov.uk/webjars/swagger-ui/index.html?configUrl=/v3/api-docs)

Template github repo used for new Kotlin based projects.
Expand All @@ -23,11 +22,16 @@ Our security policy is located [here](https://github.com/ministryofjustice/hmpps

When deploying to a new namespace, you may wish to use the
[templates project namespace](https://github.com/ministryofjustice/cloud-platform-environments/tree/main/namespaces/live.cloud-platform.service.justice.gov.uk/hmpps-templates-dev)
as the basis for your new namespace. This namespace contains both the kotlin and typescript template projects, which
is the usual way that projects are setup.
as the basis for your new namespace. This namespace contains both the kotlin and typescript template projects,
which is the usual way that projects are setup.

Copy this folder and update all the existing namespace references. If you only need the kotlin configuration then remove
all typescript references and remove the elasticache configuration. Submit a PR to the Cloud Platform team in
Copy this folder and update all the existing namespace references to correspond to the environment to which you're deploying.

If you only need the kotlin configuration then remove all typescript references and remove the elasticache configuration.

To ensure the correct github teams can approve releases, you will need to make changes to the configuration in `resources/service-account-github` where the appropriate team names will need to be added (based on [lines 98-100](https://github.com/ministryofjustice/cloud-platform-environments/blob/main/namespaces/live.cloud-platform.service.justice.gov.uk/hmpps-templates-dev/resources/serviceaccount-github.tf#L98) and the reference appended to the teams list below [line 112](https://github.com/ministryofjustice/cloud-platform-environments/blob/main/namespaces/live.cloud-platform.service.justice.gov.uk/hmpps-templates-dev/resources/serviceaccount-github.tf#L112)). Note: hmpps-sre is in this list to assist with deployment issues.

Submit a PR to the Cloud Platform team in
#ask-cloud-platform. Further instructions from the Cloud Platform team can be found in
the [Cloud Platform User Guide](https://user-guide.cloud-platform.service.justice.gov.uk/#cloud-platform-user-guide)

Expand Down Expand Up @@ -128,4 +132,3 @@ docker compose pull && docker compose up --scale hmpps-template-kotlin=0

will just start a docker instance of HMPPS Auth. The application should then be started with a `dev` active profile
in Intellij.

5 changes: 3 additions & 2 deletions helm_deploy/hmpps-template-kotlin/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ generic-service:
replicaCount: 4

image:
repository: quay.io/hmpps/hmpps-template-kotlin
repository: ghcr.io/ministryofjustice/hmpps-template-kotlin
tag: app_version # override at deployment time
port: 8080

Expand All @@ -28,10 +28,11 @@ generic-service:

namespace_secrets:
hmpps-template-kotlin:
APPINSIGHTS_INSTRUMENTATIONKEY: "APPINSIGHTS_INSTRUMENTATIONKEY"
# Example client registration secrets
EXAMPLE_API_CLIENT_ID: "TEMPLATE_KOTLIN_API_CLIENT_ID"
EXAMPLE_API_CLIENT_SECRET: "TEMPLATE_KOTLIN_API_CLIENT_SECRET"
application-insights:
APPINSIGHTS_INSTRUMENTATIONKEY: "APPINSIGHTS_INSTRUMENTATIONKEY"

allowlist:
groups:
Expand Down

0 comments on commit f0e66c3

Please sign in to comment.