forked from SAP-archive/xsk
-
Notifications
You must be signed in to change notification settings - Fork 0
120 lines (114 loc) · 3.96 KB
/
stage-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
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
name: Stage-release
on:
workflow_dispatch:
inputs:
XSK_VERSION:
description: 'XSK version'
required: true
workflow_call:
inputs:
XSK_VERSION:
required: true
type: string
XSK_HELM_SHA:
required: true
type: string
XSK_DISPATCH:
required: true
type: string
secrets:
STAGE_KYMA_CONFIG:
required: true
STAGE_HANA_URL:
required: true
STAGE_HANA_USERNAME:
required: true
STAGE_HANA_PASSWORD:
required: true
STAGE_KYMA_HOST:
required: true
STAGE_NAMESPACE:
required: true
STAGE_SERVICE_ACCOUNT:
required: true
jobs:
build:
runs-on: ubuntu-latest
steps:
#------Restore previous job---------#
- name: Composer cache
if: steps.success.outputs.cache-hit != 'true'
uses: actions/cache@v2
with:
path: vendor
key: composer-${{ hashFiles('composer.lock') }}
- run : echo "done" > success-job-${{ github.sha }}-${{ matrix.name }}
#--------Restore previous job-------#
# Set XSK Kyma context
- name: Kubernetes set context
uses: Azure/k8s-set-context@v1
with:
method: kubeconfig
kubeconfig: ${{ secrets.STAGE_KYMA_CONFIG }}
# Install helm
- uses: azure/setup-helm@v1
with:
version: 'latest' # default is latest stable
id: install
# Add repo
- name: Add XSK helm repo
run: |
sleep 5m
helm repo add xsk https://www.xsk.io
helm repo update
mkdir ~/.gnupg
wget https://xsk.io/charts/pubring.gpg -O ~/.gnupg/pubring.gpg
# Check chart sha and set XSK version
- name: Check and set XSK version
uses: nick-fields/retry@v2
with:
timeout_seconds: 5
max_attempts: 10
retry_on: error
command: |
if [[ ! -z "${{ inputs.XSK_DISPATCH }}" ]]
then
OUTPUT=$(helm pull xsk/xsk --version ${{ inputs.XSK_VERSION }} --verify)
OUTPUT="${OUTPUT//'%'/'%25'}"
OUTPUT="${OUTPUT//$'\n'/'%0A'}"
OUTPUT="${OUTPUT//$'\r'/'%0D'}"
HELM_SHA=$(echo "$OUTPUT" | tail -n1)
SHA=$(sed -e 's#.*sha256:\(\)#\1#' <<< $HELM_SHA)
if [ $SHA != ${{ inputs.XSK_HELM_SHA }} ]
then
echo "Failed to verify sha!"
exit 1
fi
echo "::set-output name=XSK_VERSION_OUTPUT::${{ inputs.XSK_VERSION }}"
else
helm pull xsk/xsk --version ${{ github.event.inputs.XSK_VERSION }} --verify
XSK_VERSION=${{ github.event.inputs.XSK_VERSION }}
echo "::set-output name=XSK_VERSION_OUTPUT::$XSK_VERSION"
fi
id: XSK_VERSION
# Deploy XSK on stage
- name: Deploy XSK helm chart
run: |
XSK_VERSION="${{ steps.XSK_VERSION.outputs.XSK_VERSION_OUTPUT }}"
helm upgrade --install xsk-stage xsk/xsk --version $XSK_VERSION -n ${{ secrets.STAGE_NAMESPACE }} \
--set hana.enabled=true \
--set hana.url="jdbc:sap://${{ secrets.STAGE_HANA_URL }}/?encrypt=true&validateCertificate=false" \
--set hana.username=${{ secrets.STAGE_HANA_USERNAME }} \
--set hana.password=${{ secrets.STAGE_HANA_PASSWORD }} \
--set kyma.enabled=true \
--set kyma.host=${{ secrets.STAGE_KYMA_HOST }} \
--set serviceAccount.name=${{ secrets.STAGE_SERVICE_ACCOUNT }} \
--set application.image=dirigiblelabs/xsk-kyma:$XSK_VERSION
# Wait for XSK Service Container to Startup
- name: Wait XSK Startup
uses: nick-invision/retry@v2
with:
timeout_seconds: 15
max_attempts: 15
warning_on_retry: false
command: curl -m 5 --silent --fail --request GET https://${{ secrets.STAGE_NAMESPACE }}.${{ secrets.STAGE_KYMA_HOST }}/services/v4/healthcheck | jq --exit-status -n 'inputs | if has("status") then .status=="Ready" else false end' > /dev/null