-
Notifications
You must be signed in to change notification settings - Fork 2
136 lines (131 loc) · 4.32 KB
/
build_push_controller.yaml
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
name: Build and push images
on:
push:
branches:
- master
paths:
- api/**
- cmd/**
- controllers/**
- ./main.go
- ./go.mod
- ./go.sum
- config/**
- ./Dockerfile
- ./Makefile
workflow_dispatch:
env:
VERSION: '0.0.1'
IMAGE_REGISTRY: ghcr.io/${{ github.repository_owner }}
jobs:
build-push-bundle:
runs-on: ubuntu-latest
needs: build-push-controller
env:
IMAGE_NAME: ghcr.io/${{ github.repository }}/core-dump-operator
BUNDLE_IMAGE_NAME: ghcr.io/${{ github.repository }}/core-dump-operator-bundle
CHANNELS: stable
DEFAULT_CHANNEL: stable
steps:
- uses: actions/checkout@v2
- uses: actions/setup-go@v2
with:
go-version: '1.19.2'
- name: set ARCH and OD
run: |
echo "ARCH=$(case $(uname -m) in x86_64) echo -n amd64 ;; aarch64) echo -n arm64 ;; *) echo -n $(uname -m) ;; esac)" >> $GITHUB_ENV
echo "OS=$(uname | awk '{print tolower($0)}')" >> $GITHUB_ENV
echo "OPERATOR_SDK_DL_URL=https://github.com/operator-framework/operator-sdk/releases/download/v1.31.0" >> $GITHUB_ENV
- name: download operator-sdk
run: curl -LO ${{ env.OPERATOR_SDK_DL_URL }}/operator-sdk_${{ env.OS }}_${{ env.ARCH }}
- name: move operator-sdk to binary path
run: chmod +x operator-sdk_${{ env.OS }}_${{ env.ARCH }} && sudo mv operator-sdk_${{ env.OS }}_${{ env.ARCH }} /usr/local/bin/operator-sdk
- name: Tidy
run: |
go mod tidy
- name: Make bundle
run: make bundle IMG=${{ env.IMAGE_NAME }}:v${{ env.VERSION }}
- name: Set up Docker
uses: docker/setup-buildx-action@v1
- name: Login to Docker
uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{ secrets.GH_USERNAME }}
password: ${{ secrets.GH_TOKEN }}
- name: Build and push bundle
uses: docker/build-push-action@v2
with:
context: .
push: true
tags: |
${{ env.BUNDLE_IMAGE_NAME }}:latest
${{ env.BUNDLE_IMAGE_NAME }}:v${{ env.VERSION }}
file: ./bundle.Dockerfile
build-push-controller:
runs-on: ubuntu-latest
env:
IMAGE_NAME: ghcr.io/${{ github.repository }}/core-dump-operator
steps:
- uses: actions/checkout@v2
- uses: actions/setup-go@v2
with:
go-version: '1.19.2'
- name: Tidy
run: |
go mod tidy
make generate fmt vet
- name: Set up Docker
uses: docker/setup-buildx-action@v1
- name: Login to Docker
uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{ secrets.GH_USERNAME }}
password: ${{ secrets.GH_TOKEN }}
- name: Build and push controller
uses: docker/build-push-action@v2
with:
context: .
push: true
tags: |
${{ env.IMAGE_NAME }}:${{ github.sha }}-${{ github.run_number }}
${{ env.IMAGE_NAME }}:latest
${{ env.IMAGE_NAME }}:v${{ env.VERSION }}
file: ./Dockerfile
build-push-uploader:
runs-on: ubuntu-latest
env:
IMAGE_NAME: ghcr.io/${{ github.repository }}/core-dump-uploader
CGO_ENABLED: 0
GOOS: linux
steps:
- uses: actions/checkout@v2
- uses: actions/setup-go@v2
with:
go-version: '1.19.2'
- name: Tidy
run: |
go mod tidy
- name: Set up Docker
uses: docker/setup-buildx-action@v1
- name: Login to Docker
uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{ secrets.GH_USERNAME }}
password: ${{ secrets.GH_TOKEN }}
- name: Build
run: |
go build -v -a -ldflags '-extldflags "-static"' -gcflags="all=-N -l" -o ./bin/core-dump-uploader ./cmd/core-dump-uploader/
cp /etc/ssl/certs/ca-certificates.crt bin/
- name: Build and push controller
uses: docker/build-push-action@v2
with:
context: ./bin/
push: true
tags: |
${{ env.IMAGE_NAME }}:${{ github.sha }}-${{ github.run_number }}
${{ env.IMAGE_NAME }}:latest
${{ env.IMAGE_NAME }}:v${{ env.VERSION }}
file: ./cmd/core-dump-uploader/Dockerfile