Skip to content

PI-1597 (#2464)

PI-1597 (#2464) #1847

Workflow file for this run

name: Pipeline
on:
push:
branches:
- main
workflow_dispatch: # Can be triggered manually from a branch
inputs:
force-deploy:
description: Force re-tagging and deployment of images
type: boolean
default: false
jobs:
build:
name: Build
uses: ./.github/workflows/build.yml
with:
push: true
force-deploy: "${{ inputs.force-deploy || false }}"
secrets: inherit
post-build:
name: Post-build
runs-on: ubuntu-latest
needs: build
outputs:
changes: ${{ steps.merge-changes.outputs.changes }}
version: ${{ needs.build.outputs.version }}
steps:
- uses: actions/checkout@v4
- name: Merge changes from the matrix build
id: merge-changes
uses: ./.github/actions/merge-changes
analyse:
name: Analyse
runs-on: ubuntu-latest
needs: build
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/analyse
with:
token: ${{ secrets.SONAR_TOKEN }}
deploy-to-test:
name: Deploy to test
uses: ./.github/workflows/deploy.yml
needs: post-build
if: ${{ needs.post-build.outputs.changes != '[]' }}
with:
environment: test
version: ${{ needs.post-build.outputs.version }}
projects: ${{ needs.post-build.outputs.changes }}
secrets: inherit
deploy-to-preprod:
name: Deploy to preprod
uses: ./.github/workflows/deploy.yml
needs: post-build
if: ${{ needs.post-build.outputs.changes != '[]'}}
with:
environment: preprod
version: ${{ needs.post-build.outputs.version }}
projects: ${{ needs.post-build.outputs.changes }}
secrets: inherit
end-to-end-tests:
name: Run end-to-end tests
uses: ministryofjustice/hmpps-probation-integration-e2e-tests/.github/workflows/test-remote.yml@main
needs:
- post-build
- deploy-to-test
- deploy-to-preprod
with:
projects: ${{ needs.post-build.outputs.changes }}
secrets:
token: ${{ secrets.BOT_GITHUB_TOKEN }}
report-test-failures:
name: Failed testing
if: ${{ failure() && needs.end-to-end-tests.outputs.failed-projects != '[]' }}
needs:
- end-to-end-tests
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
project: ${{ fromJson(needs.end-to-end-tests.outputs.failed-projects) }}
steps:
- run: 'echo Tests failed for ${{ matrix.project }}. View the full report here: ${{ needs.end-to-end-tests.outputs.report-url }}; exit 1'
deploy-to-prod:
name: Deploy to production
uses: ./.github/workflows/deploy.yml
if: ${{ (success() || (failure() && needs.end-to-end-tests.outputs.passed-projects != '[]')) && github.ref == 'refs/heads/main' }}
needs:
- post-build
- end-to-end-tests
with:
environment: prod
version: ${{ needs.post-build.outputs.version }}
projects: ${{ needs.end-to-end-tests.outputs.passed-projects }}
secrets: inherit