-
Notifications
You must be signed in to change notification settings - Fork 35
110 lines (91 loc) · 3.61 KB
/
latest-release.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
on:
push:
# Sequence of patterns matched against refs/tags
branches:
- 'dev'
- 'v*'
create:
branches:
- 'v*'
name: Create discovery engine release after testing the image
jobs:
build:
name: Create discovery engine Release
if: github.repository == 'accuknox/discovery-engine'
runs-on: ubuntu-20.04
timeout-minutes: 60
steps:
- name: Checkout discovery engine code
uses: actions/checkout@v2
- name: Setup Enviroment
id: vars
run: |
if [ ${{ github.ref }} == "refs/heads/dev" ]; then
echo ::set-output name=tag::latest
else
echo ::set-output name=tag::${GITHUB_REF#refs/*/}
fi
# setup kubernetes environment
./k3s/install_k3s.sh
- name: Generate discovery engine artifacts
run: |
GITHUB_SHA=$GITHUB_SHA ./src/build/build_knoxautopolicy.sh ${{ steps.vars.outputs.tag }}
- name: Install Kustomize
run: |
curl -s "https://raw.githubusercontent.com/kubernetes-sigs/kustomize/master/hack/install_kustomize.sh" | bash
sudo mv kustomize /usr/local/bin/
- name: Run discovery engine
run: |
docker save accuknox/knoxautopolicy:${{ steps.vars.outputs.tag }} | sudo k3s ctr images import -
kustomize build ./deployments/k8s/default/discovery-engine | sed -e 's/\(image: *\).*/\1accuknox\/knoxautopolicy:${{ steps.vars.outputs.tag }}/' -e 's/\(imagePullPolicy: *\).*/\1Never/' | kubectl apply -f -
kubectl wait --for=condition=ready --timeout=5m -n accuknox-agents pod -l app=discovery-engine
kubectl get pods -A
#TODO: add the following tests after they are fixed
# - name: Test discovery engine
# run: |
# ./tests/test-scenarios-local.sh ${{ steps.vars.outputs.tag }}
- name: Login to Docker Hub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_AUTHTOK }}
- 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: Push discovery engine images to Docker
run: |
GITHUB_SHA=$GITHUB_SHA ./src/build/push_knoxautopolicy.sh ${{ steps.vars.outputs.tag }}
push-stable-version:
name: Create discovery engine Release - 20.04
needs: build
if: github.ref != 'refs/heads/dev'
runs-on: ubuntu-20.04
timeout-minutes: 60
steps:
- name: Checkout discovery engine code
uses: actions/checkout@v2
with:
ref: dev
- name: Pull Docker Hub image
id: match
run: |
value=`cat STABLE-RELEASE`
if [ ${{ github.ref }} == refs/heads/$value ]; then
docker pull docker.io/accuknox/knoxautopolicy:$value
docker image tag accuknox/knoxautopolicy:$value accuknox/knoxautopolicy:stable
echo ::set-output name=tag::true
else
echo ::set-output name=tag::false
fi
- name: Login to Docker Hub
if: steps.match.outputs.tag == 'true'
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_AUTHTOK }}
- name: Push discovery engine images to Docker
if: steps.match.outputs.tag == 'true'
run: GITHUB_SHA=$GITHUB_SHA STABLE_VERSION=$(cat STABLE-RELEASE) ./src/build/push_knoxautopolicy.sh stable