-
Notifications
You must be signed in to change notification settings - Fork 6
129 lines (105 loc) · 3.34 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
name: Go
# Trigger the workflow on push or pull requests
on:
push:
branches:
- 'master'
tags:
- '*'
pull_request:
env:
KUBECONFIG: /tmp/kubeconfig
IMAGE_NAME: quay.io/mittwald/harbor-operator
REGISTRY_URL: quay.io/mittwald
GOLANGCI_LINT_VERSION: v1.57.2
jobs:
lint:
name: Lint
runs-on: ubuntu-latest
steps:
- name: Set up Go 1.22
uses: actions/setup-go@v2
with:
go-version: 1.22
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 "${GOLANGCI_LINT_VERSION}"
- name: Run golangci-lint
run: $(go env GOPATH)/bin/golangci-lint run -v --timeout 30m
test:
name: Test
runs-on: ubuntu-latest
steps:
- name: Set up Go 1.22
uses: actions/setup-go@v2
with:
go-version: 1.22
id: go
- name: Check out code into the Go module directory
uses: actions/checkout@v2
- name: Go Test
if: github.event_name == 'pull_request'
run: sudo ln -sf /bin/bash /bin/sh && make test
build:
name: Build Image
runs-on: ubuntu-latest
steps:
- name: Set up Go 1.22
uses: actions/setup-go@v2
with:
go-version: 1.22
id: go
- name: Check out code into the Go module directory
uses: actions/checkout@v2
- name: Build Image
run: sudo ln -sf /bin/bash /bin/sh && make docker-build
deploymaster:
name: Deploy Latest Image
runs-on: ubuntu-latest
needs: ['test', 'build']
if: github.ref == 'refs/heads/master'
steps:
- name: Set up Go 1.22
uses: actions/setup-go@v2
with:
go-version: 1.22
id: go
- name: Registry Login
run: docker login -u "${{ secrets.dockerLoginUsername }}" -p "${{ secrets.dockerLoginPassword }}" "${REGISTRY_URL}"
- name: Check out code into the Go module directory
uses: actions/checkout@v2
- name: Build latest image
run: make docker-build
- name: Push latest tag
run: make docker-push
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.22
uses: actions/setup-go@v2
with:
go-version: 1.22
id: go
- name: Registry Login
run: docker login -u "${{ secrets.dockerLoginUsername }}" -p "${{ secrets.dockerLoginPassword }}" "${REGISTRY_URL}"
- name: Check out code into the Go module directory
uses: actions/checkout@v2
- name: Build tagged image
run: make docker-build
- 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: Bump chart version
uses: mittwald/bump-app-version-action@v1
with:
mode: 'publish'
chartYaml: './deploy/chart/Chart.yaml'
env:
GITHUB_TOKEN: "${{ secrets.GITHUBTOKEN }}"
HELM_REPO_PASSWORD: "${{ secrets.HELM_REPO_PASSWORD }}"