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

HEAT-313 - implement Github workflows for test -> build -> deploy #245

Merged
merged 27 commits into from
Nov 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
6fa25d7
first pipeline for github workflow
james-jdgtl Oct 10, 2024
c246e85
add commented out branches to run on every push
james-jdgtl Oct 10, 2024
b64313d
end to end flow for build and deploy - first attempt
james-jdgtl Oct 14, 2024
8cd8cd0
full validation deployment
james-jdgtl Oct 14, 2024
b92ca90
try running the pipeline
james-jdgtl Oct 15, 2024
baef14b
refactor the workflow a bit
james-jdgtl Oct 15, 2024
fcfc2a2
change pipeline name
james-jdgtl Oct 15, 2024
bcbfa04
use the correct registry
james-jdgtl Oct 15, 2024
adcbcdd
remove deployment gate
james-jdgtl Oct 15, 2024
e34a1ae
use create app version in action
james-jdgtl Oct 15, 2024
2e339a0
bump
james-jdgtl Oct 15, 2024
b9698a1
bump to main
james-jdgtl Oct 15, 2024
f7ad579
only run on main branch
james-jdgtl Oct 16, 2024
a641c07
Bump workflow version to v1.0
james-jdgtl Oct 16, 2024
333fc22
remove CircleCI references
james-jdgtl Oct 16, 2024
3b06c00
pin to major version
james-jdgtl Oct 16, 2024
9604968
make pipeline name match the other template
james-jdgtl Oct 16, 2024
16b6081
update documentation to reference Github Actions bits
james-jdgtl Oct 16, 2024
8ad5dd8
run on all branches but only build (and deploy) on main
james-jdgtl Oct 17, 2024
13c6147
SDIT-2049: ⬆️ Upgrade to hmpps spring boot 6.0.6 for path directory t…
petergphillips Oct 11, 2024
abcc65f
Move security jobs from circleci to github actions (#243)
mattops Oct 16, 2024
3220581
end to end flow for build and deploy - first attempt
james-jdgtl Oct 14, 2024
d32f9cc
end to end flow for build and deploy - first attempt
james-jdgtl Oct 14, 2024
01fee5b
Merge branch 'main' into HEAT-313-kotlin-github-workflow
james-jdgtl Oct 17, 2024
3b63177
add preprod and prod environments as examples
james-jdgtl Oct 28, 2024
a0d39b4
change to Cloud Platform appinsights secret
james-jdgtl Nov 4, 2024
852ccff
Merge branch 'main' into HEAT-313-kotlin-github-workflow
mattops Nov 12, 2024
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
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:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wonder if on a workflow dispatch we need all these options?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've reviewed the process for CircleCI and it carries out the workflow for all branches, but only builds and deploys on main. I've updated this PR to reflect that.

environment:
description: Environment
type: choice
required: true
options:
- dev
- preprod
- staging
mattops marked this conversation as resolved.
Show resolved Hide resolved
- 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'
mattops marked this conversation as resolved.
Show resolved Hide resolved
- '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