-
Notifications
You must be signed in to change notification settings - Fork 0
142 lines (137 loc) · 5.59 KB
/
release-new-version.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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
#Release new docker image to ECR and schema to Nexus (if contains any changes)
name: Release new version
on:
workflow_call:
inputs:
gistID:
required: true
type: string
runner:
description: Runner to run the workflow
required: false
type: string
default: 'ubuntu-latest'
additional-gradle-args:
description: 'Additional arguments to pass to the Gradle commands'
required: false
type: string
default: ""
skip-behaviour-tests:
description: 'Skip running behaviour tests'
required: false
type: string
default: "false"
skip-integration-tests:
description: 'Skip running integration tests'
required: false
type: string
default: "false"
require-approval-when-deploying-to-production:
description: 'Whether auto-deploy to production should require a manual approval'
required: false
type: boolean
default: true
outputs:
version:
description: Version number of the image released to ECR
value: ${{ jobs.build.outputs.version }}
jobs:
build:
runs-on: ${{ inputs.runner }}
env:
IS_DEFAULT_BRANCH: ${{ contains('refs/heads/main, refs/heads/master', github.ref) }}
secrets: ${{ toJSON(secrets) }}
outputs:
version: ${{ steps.format-version.outputs.version }}
steps:
- id: setup-build-environment
name: "Setup build environment"
uses: sympower/sympower-composite-actions/[email protected]
with:
secrets: ${{ env.secrets }}
- id: format-version
name: "Format version"
uses: sympower/sympower-composite-actions/[email protected]
with:
style-as-release: ${{ env.IS_DEFAULT_BRANCH }}
- id: run-tests
name: "Run tests"
uses: sympower/sympower-composite-actions/[email protected]
with:
additional-gradle-args: ${{ inputs.additional-gradle-args }}
skip-behaviour-tests: ${{ inputs.skip-behaviour-tests }}
skip-integration-tests: ${{ inputs.skip-integration-tests }}
- id: code-analysis
name: "Code analysis"
uses: sympower/sympower-composite-actions/[email protected]
with:
secrets: ${{ env.secrets }}
additional-gradle-args: ${{ inputs.additional-gradle-args }}
### Steps run only in default branch ###
- id: build-and-upload-docker-image
name: "Build and upload Docker Image"
if: env.IS_DEFAULT_BRANCH == 'true'
uses: sympower/sympower-composite-actions/[email protected]
with:
version: ${{ steps.format-version.outputs.version }}
additional-gradle-args: ${{ inputs.additional-gradle-args }}
- run: echo "REPOSITORY_NAME=$(echo '${{ github.repository }}' | awk -F '/' '{print $2}')" >> $GITHUB_ENV
if: env.IS_DEFAULT_BRANCH == 'true'
shell: bash
- name: Update Service Version Badge
if: env.IS_DEFAULT_BRANCH == 'true'
uses: schneegans/[email protected]
with:
auth: ${{ secrets.GIST_SECRET }}
gistID: ${{ inputs.gistID }}
filename: ${{ env.REPOSITORY_NAME }}-service.json
label: Service Version
message: ${{ steps.format-version.outputs.version }}
color: blue
- id: upload-avro-schema
name: "Upload Avro schema"
if: env.IS_DEFAULT_BRANCH == 'true'
uses: sympower/sympower-composite-actions/[email protected]
with:
version: ${{ steps.format-version.outputs.version }}
secrets: ${{ env.secrets }}
gistID: ${{ inputs.gistID }}
additional-gradle-args: ${{ inputs.additional-gradle-args }}
- id: upload-openapi-schema
name: "Upload OpenAPI schema"
if: env.IS_DEFAULT_BRANCH == 'true'
uses: sympower/sympower-composite-actions/[email protected]
with:
version: ${{ steps.format-version.outputs.version }}
secrets: ${{ env.secrets }}
gistID: ${{ inputs.gistID }}
additional-gradle-args: ${{ inputs.additional-gradle-args }}
- id: upload-pacts
name: "Upload pacts"
if: env.IS_DEFAULT_BRANCH == 'true'
uses: sympower/sympower-composite-actions/[email protected]
with:
version: ${{ steps.format-version.outputs.version }}
- id: deploy-staging
name: "Deploy staging"
if: env.IS_DEFAULT_BRANCH == 'true'
uses: sympower/sympower-composite-actions/[email protected]
with:
secrets: ${{ env.secrets }}
version: ${{ steps.format-version.outputs.version }}
deploy-group: staging
require-approval: false
- id: deploy-production
name: "Deploy production"
if: env.IS_DEFAULT_BRANCH == 'true'
uses: sympower/sympower-composite-actions/[email protected]
with:
secrets: ${{ env.secrets }}
version: ${{ steps.format-version.outputs.version }}
deploy-group: platform
require-approval: ${{ inputs.require-approval-when-deploying-to-production }}
### End of steps run only in default branch ###
- id: upload-build-artifacts
name: "Upload build artifacts"
if: always()
uses: sympower/sympower-composite-actions/[email protected]