-
Notifications
You must be signed in to change notification settings - Fork 349
95 lines (80 loc) · 2.69 KB
/
ci-operator-release.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
name: ci-release-operator
on:
push:
branches:
- "main"
- "v*"
paths:
# release on any dependency change
- "pkg/**"
- "deployments/get/**"
- "KubeArmor/utils/**"
create:
branches:
- "v*"
# Declare default permissions as read only.
permissions: read-all
env:
PLATFORM: linux/amd64,linux/arm64/v8
jobs:
kubearmor-operator-release:
name: Build & Push KubeArmor Operator
if: github.repository == 'kubearmor/kubearmor'
runs-on: ubuntu-20.04
permissions:
id-token: write
timeout-minutes: 90
steps:
- uses: actions/checkout@v3
- uses: actions/setup-go@v5
with:
go-version-file: 'KubeArmor/go.mod'
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
with:
platforms: linux/amd64,linux/arm64/v8
- name: Login to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_AUTHTOK }}
- name: Get Tag
id: vars
run: |
if [ ${{ github.ref }} == "refs/heads/main" ]; then
echo "tag=latest" >> $GITHUB_OUTPUT
else
echo "tag=${GITHUB_REF#refs/*/}" >> $GITHUB_OUTPUT
fi
- name: Build & Push KubeArmor Operator
working-directory: ./pkg/KubeArmorOperator
run: PLATFORM=$PLATFORM make docker-buildx TAG=${{ steps.vars.outputs.tag }}
- uses: actions/checkout@v3
with:
ref: main
- name: Get and Match Stable Tag
id: stable
run: |
value=`cat STABLE-RELEASE`
if [ ${{ github.ref }} == "refs/heads/$value" ]; then
echo "match=true" >> $GITHUB_OUTPUT
else
echo "match=false" >> $GITHUB_OUTPUT
fi
- name: Install regctl
if: steps.stable.outputs.match == 'true'
run: |
curl -L https://github.com/regclient/regclient/releases/latest/download/regctl-linux-amd64 >regctl
chmod 755 regctl
mv regctl /usr/local/bin
- name: Check install
if: steps.stable.outputs.match == 'true'
run: regctl version
- name: Generate the stable version of Operator and Snitch in Docker Hub
if: steps.stable.outputs.match == 'true'
run: |
STABLE_VERSION=`cat STABLE-RELEASE`
regctl image copy kubearmor/kubearmor-operator:$STABLE_VERSION kubearmor/kubearmor-operator:stable --digest-tags
regctl image copy kubearmor/kubearmor-snitch:$STABLE_VERSION kubearmor/kubearmor-snitch:stable --digest-tags