-
Notifications
You must be signed in to change notification settings - Fork 0
129 lines (113 loc) · 3.86 KB
/
pr-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
name: CI for Pull-Request on dev
on:
pull_request:
branches: [ dev ]
env:
BUILD_TYPE: test
DOCKERHUB_USER: ${{ secrets.DOCKERHUB_USERNAME }}
DOCKERHUB_PWD: ${{ secrets.DOCKERHUB_PWD }}
GITHUB_TOKEN: ${{ secrets.WORKFLOWS_TOKEN }}
jobs:
golangci-lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: golangci-lint
uses: golangci/golangci-lint-action@v2
with:
version: v1.29
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: 1.16
- name: Build
run: go build -v ./...
unit-test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: 1.16
- name: Unit tests
run: go test -short -v ./...
integration-test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: 1.16
- name: Integration tests
run: |
printf "pulling image for MongoDB... \n\n"
docker pull mongo
printf "running container... \n\n"
docker run -d --name local-mongo -p 27888:27017 -e MONGO_INITDB_ROOT_USERNAME=admin -e MONGO_INITDB_ROOT_PASSWORD=pass mongo
go test ./... -run Integration
pr-naming-rules:
runs-on: ubuntu-latest
steps:
- uses: deepakputhraya/action-pr-title@master
with:
regex: '^(major|minor|patch)\/(feature|hotfix)\/(UBI)-([0-9]{3})-([A-Za-z-]+)$' # e.g. "major|minor|patch/{{branch name}}"
prefix_case_sensitive: false # title prefix are case insensitive
min_length: 5 # Min length of the branch name
max_length: 60 # Max length of the branch name
github_token: ${{ env.GITHUB_TOKEN }}
publish-docker:
needs: [ golangci-lint, build, pr-naming-rules ]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Prepare docker env
id: fetch-docker-vars
run: |
chmod 700 .github/tools_install.sh
./.github/tools_install.sh
IN=$(echo ${GITHUB_REPOSITORY})
NAME=${IN#"Ubivius/"}
VERSION=$(yq e '.version' ./chart/Chart.yaml)-rc
echo "::set-output name=REPO_NAME::$(echo $NAME)"
echo "::set-output name=BRANCH::$(echo $GITHUB_REF)"
echo "::set-output name=REPO_VERSION::$(echo $VERSION)"
shell: bash
- name: Build and Push Artefact to Registry
uses: elgohr/Publish-Docker-Github-Action@master
env:
BUILD_TYPE: ${{ env.BUILD_TYPE }}
with:
name: ubiviushub/${{ steps.fetch-docker-vars.outputs.REPO_NAME }}
username: ${{ env.DOCKERHUB_USER }}
password: ${{ env.DOCKERHUB_PWD }}
buildargs: BUILD_TYPE
dockerfile: Dockerfile
tags: "${{ steps.fetch-docker-vars.outputs.REPO_VERSION }}"
publish-helm:
needs: [ golangci-lint, build, pr-naming-rules ]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Prepare helm env
id: fetch-helm-vars
run: |
chmod 700 .github/tools_install.sh
./.github/tools_install.sh
- name: Package and Push Chart to ChartMuseum
run: |
IN=$(echo ${GITHUB_REPOSITORY})
NAME=${IN#"Ubivius/"}
VERSION_ACTUAL=$(yq e '.version' ./chart/Chart.yaml)-rc
yq eval -i ".version = \"$VERSION_ACTUAL\"" ./chart/Chart.yaml
yq eval -i ".appVersion = \"$VERSION_ACTUAL\"" ./chart/Chart.yaml
VERSION=$(yq e '.version' ./chart/Chart.yaml)
FULL_NAME="./${NAME}-${VERSION}.tgz"
helm package chart/
helm cm-push $FULL_NAME ysma500 -f
helm repo update