-
Notifications
You must be signed in to change notification settings - Fork 0
189 lines (165 loc) · 6.79 KB
/
manual-create-pre-release-from-dev.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
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
name: Manual create pre-release from dev
on:
workflow_dispatch:
inputs:
commit:
description: 'Pre-release type:'
type: choice
required: true
default: feat
options:
- feat
- fix
- major
defaults:
run:
shell: bash
permissions: write-all
jobs:
manual-create-pre-release:
if: github.event_name == 'workflow_dispatch' && github.ref == 'refs/heads/dev'
strategy:
matrix:
environment: [dev]
name: "manual-create-pre-release"
runs-on: ubuntu-latest
environment: ${{ matrix.environment }}
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@67fbcbb121271f7775d2e7715933280b06314838
with:
role-to-assume: ${{ secrets.IAM_ROLE }}
aws-region: ${{ vars.AWS_REGION }}
- name: Login to Amazon ECR
id: login-ecr
uses: aws-actions/amazon-ecr-login@v2
- name: Setup JDK
uses: graalvm/setup-graalvm@v1
with:
java-version: '17'
distribution: 'graalvm'
github-token: ${{ secrets.GITHUB_TOKEN }}
- name: Test and Integration tests
run: |
mvn test -Dquarkus.package.type=native -Dquarkus.application.name=atm-layer-model -Dquarkus.profile=prod
- name: Create Status check based on postman results
id: process-postman
uses: im-open/[email protected]
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
results-file: src/test/resources/integration-test/output/result.json
report-name: 'Postman create pre-release: ${{ github.run_number }}'
create-status-check: true
create-pr-comment: true
update-comment-if-one-exists: true
ignore-test-failures: true
timezone: 'europe/rome'
- name: Fail if there were errors in the postman tests
if: steps.process-postman.outputs.test-outcome == 'Failed'
run: |
echo "There were postman failures."
exit 1
- name: Upload result.html
uses: actions/upload-artifact@v3
with:
name: html-report
path: src/test/resources/integration-test/output/result.html
- name: JaCoCo Code Coverage Report
id: jacoco_reporter
uses: PavanMudigonda/[email protected]
with:
coverage_results_path: target/jacoco-report/jacoco.xml
coverage_report_name: 'Coverage create pre-release: ${{ github.run_number }}'
coverage_report_title: JaCoCo
github_token: ${{ secrets.GITHUB_TOKEN }}
skip_check_run: false
minimum_coverage: 90
fail_below_threshold: false
publish_only_summary: false
- name: Fail Build if overall coverage is less than 90%
if: steps.jacoco_reporter.outputs.coverage_percentage < 90.0
uses: actions/github-script@v6
with:
script: |
core.setFailed('Overall coverage is less than 90%!')
- name: Build docker image
env:
REGISTRY: ${{ steps.login-ecr.outputs.registry }}
REPOSITORY: ${{ vars.DOCKER_IMAGE_NAME}}
DOCKER_IMAGE_TAG: ${{ github.sha }}
run: |
docker build -f src/main/java/it/gov/pagopa/atmlayer/service/model/docker/Dockerfile.native -t $REGISTRY/$REPOSITORY:$DOCKER_IMAGE_TAG . \
--build-arg QUARKUS_PROFILE=prod \
--build-arg APP_NAME=atm-layer-model
- name: Commit with "${{ inputs.commit }}:" prefix
run: |
git config user.name "GitHub Action"
git config user.email "[email protected]"
git pull
git add .
git commit --allow-empty -m "${{ inputs.commit }}: ${{ github.sha }}"
git push
- name: Semantic Release
id: semantic-release-dryrun
uses: cycjimmy/semantic-release-action@bdd914ff2423e2792c73475f11e8da603182f32d
with:
dry_run: true
semantic_version: 19
extra_plugins: |
@semantic-release/[email protected]
@semantic-release/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Commit with "${{ inputs.commit }}:" prefix
run: |
git config user.name "GitHub Action"
git config user.email "[email protected]"
git pull
git add .
git commit --allow-empty -m "${{ inputs.commit }}: docker-image: v${{ steps.semantic-release-dryrun.outputs.new_release_version }}, chart: v${{ steps.semantic-release-dryrun.outputs.new_release_version }}"
git push
- name: Semantic Release
id: semantic-release
uses: cycjimmy/semantic-release-action@bdd914ff2423e2792c73475f11e8da603182f32d
with:
semantic_version: 19
extra_plugins: |
@semantic-release/[email protected]
@semantic-release/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Update file pom.xml with the new version
if: steps.semantic-release.outputs.new_release_published == 'true'
run: |
mvn versions:set -DnewVersion=${{ steps.semantic-release.outputs.new_release_version }} --no-transfer-progress
git pull
git config user.name "GitHub Action"
git config user.email "[email protected]"
git add pom.xml
git commit -m "pom.xml updated with new version ${{ steps.semantic-release.outputs.new_release_version }}"
git push
- name: Update file Chart.yaml with the new version
if: steps.semantic-release.outputs.new_release_published == 'true'
run: |
yq -i ".version = \"v${{ steps.semantic-release.outputs.new_release_version }}\"" "helm-chart/Chart.yaml"
git pull
git add "helm-chart/Chart.yaml"
git commit -m "Chart.yaml updated with new version v${{ steps.semantic-release.outputs.new_release_version }}"
git push
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@67fbcbb121271f7775d2e7715933280b06314838
with:
role-to-assume: ${{ secrets.IAM_ROLE }}
aws-region: ${{ vars.AWS_REGION }}
- name: Tag and push docker image on ECR
if: steps.semantic-release.outputs.new_release_published == 'true'
env:
REGISTRY: ${{ steps.login-ecr.outputs.registry }}
REPOSITORY: ${{ vars.DOCKER_IMAGE_NAME}}
DOCKER_IMAGE_TAG: ${{ github.sha }}
ECR_IMAGE_TAG: "v${{ steps.semantic-release.outputs.new_release_version }}"
run: |
docker tag $REGISTRY/$REPOSITORY:$DOCKER_IMAGE_TAG $REGISTRY/$REPOSITORY:$ECR_IMAGE_TAG
docker push $REGISTRY/$REPOSITORY:$ECR_IMAGE_TAG