-
Notifications
You must be signed in to change notification settings - Fork 60
141 lines (113 loc) · 4.77 KB
/
workflow.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
name: Go
# Trigger the workflow on push or pull request
on:
push:
branches:
- 'master'
tags:
- '*'
pull_request:
env:
KUBECONFIG: /tmp/kubeconfig
OPERATOR_SDK_VERSION: v0.18.2
IMAGE_NAME: quay.io/mittwald/kubernetes-secret-generator
jobs:
test:
name: Test
runs-on: ubuntu-latest
steps:
- name: Set up Go 1.15
uses: actions/setup-go@v1
with:
go-version: 1.15
id: go
- name: Check out code into the Go module directory
uses: actions/checkout@v2
- name: Install golangci-lint
run: curl -sfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh| sh -s -- -b $(go env GOPATH)/bin v1.33.0
- name: Run golangci-lint
run: $(go env GOPATH)/bin/golangci-lint run -v --timeout 5m
- name: Create kind cluster and apply crds
run: make crd
- name: Hack Code Climate and Go Modules
if: github.event_name != 'pull_request'
run: mkdir -p github.com/mittwald && ln -sf $(pwd) github.com/mittwald/kubernetes-secret-generator
- name: Test & publish code coverage
if: github.event_name != 'pull_request'
uses: paambaati/codeclimate-action@v2.3.0
env:
CC_TEST_REPORTER_ID: ${{ secrets.codeClimateReporterID }}
with:
coverageCommand: go test -coverprofile=c.out ./...
debug: true
prefix: 'github.com/${{ github.repository }}/'
- name: Go Test
if: github.event_name == 'pull_request'
run: go test -coverprofile=c.out -coverpkg=./pkg/... ./...
build:
name: Build Image
runs-on: ubuntu-latest
steps:
- name: Set up Go 1.15
uses: actions/setup-go@v1
with:
go-version: 1.15
id: go
- name: Check out code into the Go module directory
uses: actions/checkout@v2
- name: Install operator-sdk
run: sudo curl -L -o /usr/local/bin/operator-sdk "https://github.com/operator-framework/operator-sdk/releases/download/${OPERATOR_SDK_VERSION}/operator-sdk-${OPERATOR_SDK_VERSION}-x86_64-linux-gnu" && sudo chmod +x /usr/local/bin/operator-sdk
- name: Build Image
run: operator-sdk build "$IMAGE_NAME:latest" --go-build-args "-ldflags -X=version.Version=${GITHUB_SHA::8}"
deploymaster:
name: Deploy Latest Image
runs-on: ubuntu-latest
needs: ['test', 'build']
if: github.ref == 'refs/heads/master'
steps:
- name: Set up Go 1.15
uses: actions/setup-go@v1
with:
go-version: 1.15
id: go
- name: Registry Login
run: docker login -u "${{ secrets.dockerLoginUsername }}" -p "${{ secrets.dockerLoginPassword }}" quay.io
- name: Check out code into the Go module directory
uses: actions/checkout@v2
- name: Install operator-sdk
run: sudo curl -L -o /usr/local/bin/operator-sdk "https://github.com/operator-framework/operator-sdk/releases/download/${OPERATOR_SDK_VERSION}/operator-sdk-${OPERATOR_SDK_VERSION}-x86_64-linux-gnu" && sudo chmod +x /usr/local/bin/operator-sdk
- name: Build latest image
run: operator-sdk build "$IMAGE_NAME:latest" --go-build-args "-ldflags -X=version.Version=${GITHUB_SHA::8}"
- name: Push latest tag
run: docker push "$IMAGE_NAME:latest"
deploytagged:
name: Deploy Tagged Image
runs-on: ubuntu-latest
needs: ['test', 'build']
if: startsWith(github.ref, 'refs/tags/v')
steps:
- name: Set up Go 1.15
uses: actions/setup-go@v1
with:
go-version: 1.15
id: go
- name: Registry Login
run: docker login -u "${{ secrets.dockerLoginUsername }}" -p "${{ secrets.dockerLoginPassword }}" quay.io
- name: Check out code into the Go module directory
uses: actions/checkout@v2
- name: Install operator-sdk
run: sudo curl -L -o /usr/local/bin/operator-sdk "https://github.com/operator-framework/operator-sdk/releases/download/${OPERATOR_SDK_VERSION}/operator-sdk-${OPERATOR_SDK_VERSION}-x86_64-linux-gnu" && sudo chmod +x /usr/local/bin/operator-sdk
- name: Build tagged image
run: operator-sdk build "$IMAGE_NAME:latest" --go-build-args "-ldflags -X=version.Version=${GITHUB_REF##*/}"
- name: Tag versioned image
run: docker tag "$IMAGE_NAME:latest" "$IMAGE_NAME:${GITHUB_REF##*/}"
- name: Push images
run: docker push "$IMAGE_NAME:latest" && docker push "$IMAGE_NAME:${GITHUB_REF##*/}"
- name: Run chart version bump
uses: mittwald/bump-app-version-action@v1
with:
mode: 'publish'
chartYaml: './deploy/helm-chart/kubernetes-secret-generator/Chart.yaml'
env:
GITHUB_TOKEN: "${{ secrets.RELEASE_USER_TOKEN }}"
HELM_REPO_PASSWORD: "${{ secrets.HELM_REPO_PASSWORD }}"