-
Notifications
You must be signed in to change notification settings - Fork 66
121 lines (121 loc) · 4.63 KB
/
operatorBuildAndDeploy.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
name: Cass Operator Build & Deploy
on:
push:
branches:
- master
- 1.10.x
pull_request:
branches: [ master ]
jobs:
testing:
name: Run unit tests
runs-on: ubuntu-latest
env:
CGO_ENABLED: 0
steps:
- uses: actions/checkout@v3
if: github.event_name == 'pull_request'
with:
ref: ${{ github.event.pull_request.head.sha }}
- uses: actions/checkout@v3
if: github.event_name != 'pull_request'
- name: Set up Go
uses: actions/setup-go@v3
with:
go-version-file: 'go.mod'
cache: true
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: golangci-lint
uses: golangci/golangci-lint-action@v3
with:
version: latest
# GHA requires longer timeout
args: --timeout=10m
# Optional: show only new issues if it's a pull request. The default value is `false`.
only-new-issues: ${{ github.event_name == 'pull_request' }}
skip-pkg-cache: true
skip-build-cache: true
- name: Verify manifests and dirty state
run: |
make manifests generate
git update-index -q --really-refresh
git diff-files --quiet
- name: Unit Tests
run: |
make test
build_images:
name: Build Cass Operator Docker Image
runs-on: ubuntu-latest
needs: testing
if: github.ref == 'refs/heads/master'
steps:
- name: Check out code into the Go module directory
uses: actions/checkout@v3
- name: Set up Go
uses: actions/setup-go@v3
with:
go-version-file: 'go.mod'
cache: true
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Login to DockerHub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_HUB_USERNAME }}
password: ${{ secrets.DOCKER_HUB_PASSWORD }}
- name: Set git parsed values
id: vars
run: |
echo "sha_short=$(git rev-parse --short=8 ${{ github.sha }})" >> $GITHUB_OUTPUT
echo "tag_name=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT
echo "version=$(make version)" >> $GITHUB_OUTPUT
- name: Build and push
id: docker_build_cass_operator
uses: docker/build-push-action@v3
with:
file: Dockerfile
context: .
push: ${{ github.event_name != 'pull_request' }}
tags: k8ssandra/cass-operator:${{ steps.vars.outputs.sha_short }}, k8ssandra/cass-operator:latest, k8ssandra/cass-operator:${{ steps.vars.outputs.version }}
platforms: linux/amd64
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache
- name: Build and push
id: docker_build_system_logger
uses: docker/build-push-action@v3
with:
file: logger.Dockerfile
push: ${{ github.event_name != 'pull_request' }}
tags: k8ssandra/system-logger:${{ steps.vars.outputs.sha_short }}, k8ssandra/system-logger:latest, k8ssandra/system-logger:${{ steps.vars.outputs.version }}
platforms: linux/amd64
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache
# The runners already have the latest versions of tools, no need to reinstall them
- name: Link tools
shell: bash
run: |
mkdir bin
ln -s /usr/local/bin/kustomize bin/kustomize
- name: Create bundle and validate
run: |
make IMG=k8ssandra/cass-operator:${{ steps.vars.outputs.version }} VERSION=${{ steps.vars.outputs.version }} CHANNEL=dev bundle
bin/operator-sdk bundle validate ./bundle --select-optional suite=operatorframework
bin/operator-sdk bundle validate ./bundle --select-optional name=operatorhub
bin/operator-sdk bundle validate ./bundle --select-optional name=good-practices
- name: Build and push cass-operator-bundle
id: docker_build_cass-operator_bundle
uses: docker/build-push-action@v3
with:
file: bundle.Dockerfile
build-args: |
VERSION=${{ steps.vars.outputs.version }}
context: .
push: ${{ !env.ACT }}
tags: k8ssandra/cass-operator-bundle:v${{ steps.vars.outputs.version }}
platforms: linux/amd64
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache
- name: Build and update cass-operator-catalog
run: |
make VERSION=${{ steps.vars.outputs.version }} CHANNEL=dev catalog-build catalog-push