Skip to content

Commit

Permalink
PI-2777 Testing branch deploy workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
marcus-bcl committed Jan 29, 2025
1 parent ff3d305 commit 682d294
Show file tree
Hide file tree
Showing 3 changed files with 160 additions and 145 deletions.
2 changes: 1 addition & 1 deletion .github/actions/render-project-template/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ runs:
cp -R templates/projects/${{ inputs.project_template }} projects/${{ inputs.project_name }}
sed -i '/add new projects here/a \ "${{ inputs.project_name }}",' settings.gradle.kts
sed -i '/add new projects here/i \ - '"'"'["${{ inputs.project_name }}"]'"'"'' .github/workflows/access.yml
sed -i '/add new projects here/i \ - '"'"'["${{ inputs.project_name }}"]'"'"'' .github/workflows/deploy.yml
sed -i '/add new projects here/i \ - '"'"'["${{ inputs.project_name }}"]'"'"'' .github/workflows/service-catalogue.yml
sed -i '/add new projects here/i \ - ${{ inputs.project_name }}' .github/workflows/build.yml
sed -i '/add new projects here/i \ - ${{ inputs.project_name }}' .github/workflows/deploy-branch.yml
sed -i '/add new projects here/i \* [${{ steps.project_name.outputs.title_case }}](https://ministryofjustice.github.io/hmpps-probation-integration-services/tech-docs/projects/${{ inputs.project_name }})' doc/tech-docs/source/services.html.md.erb
sed 's/$SERVICE_NAME/${{ inputs.project_name }}/g' templates/runConfiguration.xml > '.idea/runConfigurations/${{ inputs.project_name }}.run.xml'
Expand Down
90 changes: 90 additions & 0 deletions .github/workflows/deploy-branch.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
name: Deploy branch
on:
workflow_dispatch:
inputs:
project:
description: Project
type: choice
required: true
options:
- accredited-programmes-and-oasys
- approved-premises-and-delius
- approved-premises-and-oasys
- arns-and-delius
- assessment-summary-and-delius
- cas2-and-delius
- cas3-and-delius
- core-person-record-and-delius
- court-case-and-delius
- create-and-vary-a-licence-and-delius
- custody-key-dates-and-delius
- domain-events-and-delius
- dps-and-delius
- effective-proposal-framework-and-delius
- external-api-and-delius
- feature-flags
- hdc-licences-and-delius
- hmpps-auth-and-delius
- make-recall-decisions-and-delius
- manage-offences-and-delius
- manage-pom-cases-and-delius
- manage-supervision-and-delius
- manage-supervision-and-oasys
- oasys-and-delius
- offender-events-and-delius
- opd-and-delius
- pathfinder-and-delius
- person-search-index-from-delius
- pre-sentence-reports-to-delius
- prison-case-notes-to-probation
- prison-custody-status-to-delius
- prison-education-and-delius
- prison-identifier-and-delius
- prisoner-profile-and-delius
- probation-search-and-delius
- redrive-dead-letter-queue
- refer-and-monitor-and-delius
- resettlement-passport-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
- subject-access-requests-and-delius
- common-platform-and-delius
- ims-and-delius
- appointment-reminders-and-delius
- justice-email-and-delius
- assess-for-early-release-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
environment:
description: Environment
type: choice
required: true
options:
- test
- preprod
- prod

jobs:
build:
name: Build
uses: ./.github/workflows/build.yml
with:
push: true
force-deploy: true
secrets:
GRADLE_ENCRYPTION_KEY: ${{ secrets.GRADLE_ENCRYPTION_KEY }}

deploy:
name: Deploy
uses: ./.github/workflows/deploy.yml
needs: build
with:
projects: '["${{ inputs.project }}"]'
environment: inputs.environment
version: needs.build.outputs.version
213 changes: 69 additions & 144 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -1,79 +1,63 @@
name: Deploy

name: Deploy branch
on:
workflow_call:
inputs:
projects:
description: A JSON array of projects to deploy
type: string
required: true
environment:
description: The environment name to deploy to (test/preprod/prod)
type: string
required: true
version:
description: The image version to deploy
type: string
required: true

workflow_dispatch:
inputs:
projects:
project:
description: Project
type: choice
required: true
options:
- '["accredited-programmes-and-oasys"]'
- '["approved-premises-and-delius"]'
- '["approved-premises-and-oasys"]'
- '["arns-and-delius"]'
- '["assessment-summary-and-delius"]'
- '["cas2-and-delius"]'
- '["cas3-and-delius"]'
- '["core-person-record-and-delius"]'
- '["court-case-and-delius"]'
- '["create-and-vary-a-licence-and-delius"]'
- '["custody-key-dates-and-delius"]'
- '["domain-events-and-delius"]'
- '["dps-and-delius"]'
- '["effective-proposal-framework-and-delius"]'
- '["external-api-and-delius"]'
- '["feature-flags"]'
- '["hdc-licences-and-delius"]'
- '["hmpps-auth-and-delius"]'
- '["make-recall-decisions-and-delius"]'
- '["manage-offences-and-delius"]'
- '["manage-pom-cases-and-delius"]'
- '["manage-supervision-and-delius"]'
- '["manage-supervision-and-oasys"]'
- '["oasys-and-delius"]'
- '["offender-events-and-delius"]'
- '["opd-and-delius"]'
- '["pathfinder-and-delius"]'
- '["person-search-index-from-delius"]'
- '["pre-sentence-reports-to-delius"]'
- '["prison-case-notes-to-probation"]'
- '["prison-custody-status-to-delius"]'
- '["prison-education-and-delius"]'
- '["prison-identifier-and-delius"]'
- '["prisoner-profile-and-delius"]'
- '["probation-search-and-delius"]'
- '["redrive-dead-letter-queue"]'
- '["refer-and-monitor-and-delius"]'
- '["resettlement-passport-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"]'
- '["subject-access-requests-and-delius"]'
- '["common-platform-and-delius"]'
- '["ims-and-delius"]'
- '["appointment-reminders-and-delius"]'
- '["justice-email-and-delius"]'
- '["assess-for-early-release-and-delius"]'
- accredited-programmes-and-oasys
- approved-premises-and-delius
- approved-premises-and-oasys
- arns-and-delius
- assessment-summary-and-delius
- cas2-and-delius
- cas3-and-delius
- core-person-record-and-delius
- court-case-and-delius
- create-and-vary-a-licence-and-delius
- custody-key-dates-and-delius
- domain-events-and-delius
- dps-and-delius
- effective-proposal-framework-and-delius
- external-api-and-delius
- feature-flags
- hdc-licences-and-delius
- hmpps-auth-and-delius
- make-recall-decisions-and-delius
- manage-offences-and-delius
- manage-pom-cases-and-delius
- manage-supervision-and-delius
- manage-supervision-and-oasys
- oasys-and-delius
- offender-events-and-delius
- opd-and-delius
- pathfinder-and-delius
- person-search-index-from-delius
- pre-sentence-reports-to-delius
- prison-case-notes-to-probation
- prison-custody-status-to-delius
- prison-education-and-delius
- prison-identifier-and-delius
- prisoner-profile-and-delius
- probation-search-and-delius
- redrive-dead-letter-queue
- refer-and-monitor-and-delius
- resettlement-passport-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
- subject-access-requests-and-delius
- common-platform-and-delius
- ims-and-delius
- appointment-reminders-and-delius
- justice-email-and-delius
- assess-for-early-release-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
Expand All @@ -85,81 +69,22 @@ on:
- test
- preprod
- prod
version:
description: Image version
type: string
required: true

jobs:
deploy:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
project: ${{ fromJson(inputs.projects) }}
concurrency: deploy-${{ matrix.project }}-${{ inputs.environment }}
environment:
name: ${{ inputs.environment }}
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/get-env-details
id: env
with:
environment: ${{ inputs.environment }}

- name: Get enabled flag from values file
id: enabled
shell: bash
run: echo "enabled=$(yq '.enabled' "$VALUES_FILE" | sed 's/^null$/true/')" | tee -a "$GITHUB_OUTPUT"
working-directory: projects/${{ matrix.project }}/deploy
env:
VALUES_FILE: ${{ steps.env.outputs.values-file }}

- name: Check Chart.yaml file exists
id: check_files
uses: andstor/file-existence-action@076e0072799f4942c8bc574a82233e1e4d13e9d6 # v2
with:
files: projects/${{ matrix.project }}/deploy/Chart.yaml

- name: Deploy to Cloud Platform
if: ${{ steps.check_files.outputs.files_exists == 'true' && steps.enabled.outputs.enabled == 'true' }}
uses: ./.github/actions/cloud-platform-deploy
with:
project: ${{ matrix.project }}
environment: ${{ inputs.environment }}
version: ${{ inputs.version }}
api: ${{ secrets.KUBE_ENV_API }}
cert: ${{ secrets.KUBE_CERT }}
cluster: ${{ secrets.KUBE_CLUSTER }}
namespace: ${{ secrets.KUBE_NAMESPACE }}
token: ${{ secrets.KUBE_TOKEN }}
ip-allowlists: ${{ vars.HMPPS_IP_ALLOWLIST_GROUPS_YAML }}
gradle-encryption-key: ${{ secrets.GRADLE_ENCRYPTION_KEY }}
build:
name: Build
uses: ./.github/workflows/build.yml
with:
push: true
force-deploy: true
secrets:
GRADLE_ENCRYPTION_KEY: ${{ secrets.GRADLE_ENCRYPTION_KEY }}

- uses: docker/login-action@v3
if: ${{ steps.check_files.outputs.files_exists == 'true' && steps.enabled.outputs.enabled == 'true' }}
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ github.token }}

- name: Tag image with environment
if: ${{ steps.check_files.outputs.files_exists == 'true' && steps.enabled.outputs.enabled == 'true' }}
run: |
docker pull "$image:${{ inputs.version }}"
docker pull "$image:${{ inputs.environment }}" && docker image tag "$image:${{ inputs.environment }}" "$image:${{ inputs.environment }}-prev"
docker image tag "$image:${{ inputs.version }}" "$image:${{ inputs.environment }}"
docker push --all-tags "$image"
env:
image: ghcr.io/ministryofjustice/hmpps-probation-integration-services/${{ matrix.project }}

- name: Create Sentry release
if: ${{ steps.check_files.outputs.files_exists == 'true' && steps.enabled.outputs.enabled == 'true' }}
uses: getsentry/action-release@v1
env:
SENTRY_ORG: ministryofjustice
SENTRY_PROJECT: ${{ matrix.project }}
SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }}
with:
environment: ${{ inputs.environment }}
version: ${{ inputs.version }}
deploy:
name: Deploy
uses: ./.github/workflows/deploy.yml
needs: build
with:
projects: '["${{ inputs.project }}"]'
environment: inputs.environment
version: needs.build.outputs.version

0 comments on commit 682d294

Please sign in to comment.