-
Notifications
You must be signed in to change notification settings - Fork 0
142 lines (124 loc) · 4.24 KB
/
push-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
name: CI for Merge on dev
on:
push:
tags:
- v*
branches: [ dev ]
env:
BUILD_TYPE: test
DOCKERHUB_USER: ${{ secrets.DOCKERHUB_USERNAME }}
DOCKERHUB_PWD: ${{ secrets.DOCKERHUB_PWD }}
GKE_USER: ${{ secrets.GKE_SERVICEACCOUNT_EMAIL }}
GKE_JSON: ${{ secrets.GKE_SERVICEACCOUNT_JSONKEY }}
GKE_CLUSTER_NAME: ${{ secrets.GKE_DEV_CLUSTER_NAME }}
GKE_CLUSTER_ZONE: ${{ secrets.GKE_DEV_CLUSTER_ZONE }}
GKE_CLUSTER_PROJECT: ${{ secrets.GKE_DEV_CLUSTER_PROJECT }}
LKE_SERVICEACCOUNT_TOKEN: ${{ secrets.LKE_SERVICEACCOUNT_TOKEN }}
LKE_CLUSTERID: ${{ secrets.LKE_DEV_CLUSTERID }}
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
publish-docker:
needs: [ golangci-lint, build ]
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)
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 ]
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=$(yq e '.version' ./chart/Chart.yaml)
FULL_NAME="./${NAME}-${VERSION}.tgz"
helm package chart/
helm cm-push $FULL_NAME ysma500 -f
helm repo update
deployment-lke:
needs: [ publish-docker, publish-helm ]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Prepare deploy env
run: |
chmod 700 .github/tools_install.sh
./.github/tools_install.sh
curl -H "Authorization: Bearer ${{ env.LKE_SERVICEACCOUNT_TOKEN }}" https://api.linode.com/v4/lke/clusters/${{ env.LKE_CLUSTERID }}/kubeconfig | jq '.kubeconfig' | sed 's/["]//g' | base64 --decode > ~/.kube/config
- name: Push with valuefile
run: |
IN=$(echo ${GITHUB_REPOSITORY})
NAME=${IN#"Ubivius/"}
VERSION=$(yq e '.version' ./chart/Chart.yaml)
helm upgrade $NAME --install --version $VERSION ysma500/$NAME -f chart/values.yaml