generated from ministryofjustice/template-repository
-
Notifications
You must be signed in to change notification settings - Fork 0
103 lines (94 loc) · 2.83 KB
/
pipeline.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
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: ./.github/workflows/end-to-end-tests.yml
needs:
- post-build
- deploy-to-test
- deploy-to-preprod
with:
projects: ${{ needs.post-build.outputs.changes }}
secrets: inherit
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