-
Notifications
You must be signed in to change notification settings - Fork 9
144 lines (110 loc) · 4.03 KB
/
master_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
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
name: 1/3 Main Pipeline
on:
push:
workflow_dispatch:
env:
KOSLI_ORG: kosli
KOSLI_FLOW: loancalculator
KOSLI_CLI_VERSION: "2.6.1"
IMAGE_NAME: merkely/loancalculator
jobs:
build:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v2
- name: Add Docker image names to GITHUB_ENV
run: |
echo "IMAGE_TAGGED=${{ env.IMAGE_NAME }}:$(git log -1 --pretty=%h)" >> ${GITHUB_ENV}
echo "IMAGE_LATEST=${{ env.IMAGE_NAME }}:latest" >> ${GITHUB_ENV}
- name: Setup cli client
uses: kosli-dev/setup-cli-action@v2
with:
version: ${{ env.KOSLI_CLI_VERSION }}
- name: Create Kosli flow
env:
KOSLI_API_TOKEN: ${{ secrets.KOSLI_API_TOKEN }}
run:
kosli create flow ${{ env.KOSLI_FLOW }}
--description "The loan calculator application"
--template "jira,artifact,unit_test,coverage"
--visibility public
- name: Report jira ticket to kosli
env:
KOSLI_API_TOKEN: ${{ secrets.KOSLI_API_TOKEN }}
KOSLI_JIRA_API_TOKEN: ${{ secrets.KOSLI_JIRA_API_TOKEN }}
run:
kosli report evidence commit jira
--jira-base-url https://kosli-test.atlassian.net
--jira-username [email protected]
--name jira
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Login to DockerHub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKERHUB_DEPLOY_USERNAME }}
password: ${{ secrets.DOCKERHUB_DEPLOY_TOKEN }}
- name: Build and push Docker image
id: docker_build
uses: docker/build-push-action@v2
with:
push: true
tags: ${{ env.IMAGE_TAGGED }}
cache-from: type=registry,ref=${{ env.IMAGE_NAME }}:buildcache
cache-to: type=registry,ref=${{ env.IMAGE_NAME }}:buildcache,mode=max
build-args: |
COMMIT_SHA=${{ github.sha }}
- name: Make the image digest available for following steps
id: digest-prep
run: |
ARTIFACT_SHA=$( echo ${{ steps.docker_build.outputs.digest }} | sed 's/.*://')
echo "KOSLI_FINGERPRINT=$ARTIFACT_SHA" >> ${GITHUB_ENV}
- name: Log Docker image in Kosli
env:
KOSLI_API_TOKEN: ${{ secrets.KOSLI_API_TOKEN }}
run:
kosli report artifact ${{ env.IMAGE_TAGGED }}
- name: Run unit tests
run: |
# Write results to ./build/test/
docker run \
--name container \
--entrypoint ./entrypoint-unit_test.sh \
${{ env.IMAGE_TAGGED }}
mkdir -p build/test
docker cp container:/code/build/test/ ${PWD}/build
docker rm container
- name: Log unit test results in Kosli
env:
KOSLI_API_TOKEN: ${{ secrets.KOSLI_API_TOKEN }}
run:
kosli report evidence artifact junit
--name unit_test
--results-dir "${{ github.workspace }}/build/test"
- name: Run coverage
run: |
# Write summary to build/coverage/coverage_summary.sh
mkdir -p build/coverage
docker run \
--rm \
--volume ${PWD}/build:/code/build \
--entrypoint ./entrypoint-coverage.sh \
${{ env.IMAGE_TAGGED }}
source build/coverage/coverage_summary.sh
echo "COVERAGE_SUMMARY=${COVERAGE_SUMMARY}" >> ${GITHUB_ENV}
- name: Log coverage results in Kosli
env:
KOSLI_API_TOKEN: ${{ secrets.KOSLI_API_TOKEN }}
run:
kosli report evidence artifact generic
--description "${{ env.COVERAGE_SUMMARY }}"
--name coverage
- name: Deploy to staging
run: |
echo YOUR DEPLOYMENT COMMAND HERE
- name: Log deployment to staging in Kosli
env:
KOSLI_API_TOKEN: ${{ secrets.KOSLI_API_TOKEN }}
run:
kosli expect deployment
--environment staging