-
Notifications
You must be signed in to change notification settings - Fork 0
executable file
·112 lines (100 loc) · 3.83 KB
/
operator-docker-build-push.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
#
# Copyright 2021 - now, the original author or authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
name: Operator Docker
on:
push:
tags:
- 'v*.*.*'
jobs:
build:
name: Build & Push
runs-on: ubuntu-latest
steps:
- uses: actions/[email protected]
name: Checkout
- name: Prepare Variables
id: prepare
run: |
DOCKER_IMAGE=monime/bookkeeper-operator
VERSION=${GITHUB_REF#refs/tags/}
TAGS="${DOCKER_IMAGE}:${VERSION},${DOCKER_IMAGE}:latest"
echo ::set-output name=version::${VERSION}
echo ::set-output name=tags::${TAGS}
echo ::set-output name=created::$(date -u +'%Y-%m-%dT%H:%M:%SZ')
- name: Setup Go
uses: actions/setup-go@v4
with:
go-version: 1.20
- uses: actions/cache@v2
with:
path: |
~/.cache/go-build
~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- name: Install Dependencies
run: |
curl https://raw.githubusercontent.com/helm/helm/master/scripts/get-helm-3 | bash
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Login to DockerHub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_TOKEN }}
- uses: docker/build-push-action@v2
name: Build and Deploy
with:
push: true
file: deployments/docker/operator/Dockerfile
tags: ${{ steps.prepare.outputs.tags }}
labels: |
org.opencontainers.image.title=${{ github.event.repository.name }}
org.opencontainers.image.description=${{ github.event.repository.description }}
org.opencontainers.image.version=${{ steps.prepare.outputs.version }}
org.opencontainers.image.created=${{ steps.prepare.outputs.created }}
org.opencontainers.image.revision=${{ github.sha }}
- name: Build Helm and Manifest
id: helm
run: |
git config --global pull.ff only
git clone https://.:${{ secrets.GITHUB_TOKEN }}@github.com/monimesl/helm-charts.git output
TAG=${{ steps.prepare.outputs.version }}
deployments/charts/build-helm.sh $TAG output
helm repo index --url https://monimesl.github.io/helm-charts/ output --merge output/index.yaml
echo ::set-output name=tag::${TAG}
- name: Index Helm Chart
uses: cpina/github-action-push-to-another-repository@main
with:
source-directory: 'output'
destination-github-username: 'monimesl'
destination-repository-name: 'helm-charts'
user-email: [email protected]
target-branch: main
env:
API_TOKEN_GITHUB: ${{ secrets.ACCESS_TOKEN_GITHUB }}
- name: Update Readme
run: |
LATEST_TAG=${{ steps.helm.outputs.tag }}
sed -i "s|__latest_tag__|$LATEST_TAG|" README.md
- name: Commit Manifests
uses: EndBug/add-and-commit@v7
with:
message: "🤖 - CI bot add install manifests and update README.md"
add: "deployments/manifest.yaml README.md"
branch: main
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}