-
Notifications
You must be signed in to change notification settings - Fork 58
106 lines (98 loc) · 3.99 KB
/
deploy.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
name: Deployment
on:
workflow_run:
workflows: ["Continuous Integration"]
types: [completed]
pull_request:
types: [labeled]
jobs:
build-frontend:
runs-on: self-hosted
if: "${{ (github.event.workflow_run.conclusion == 'success' && github.event.workflow_run.event == 'pull_request' && github.event.label.name == 'Action: Deploy PR') || (github.event.action == 'labeled' && github.event.label.name == 'Action: Deploy PR')}}"
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Docker meta
id: meta
uses: docker/metadata-action@v3
with:
images: |
registry.kube.com/scrumlr-frontend
tags: |
type=ref,event=pr
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
with:
driver: docker
- name: Build and push Frontend
uses: docker/build-push-action@v2
with:
push: true
tags: ${{ steps.meta.outputs.tags }}
cache-from: type=registry,ref=registry.kube.com/scrumlr-frontend:latest
cache-to: type=inline
build-server:
runs-on: self-hosted
if: "${{ (github.event.workflow_run.conclusion == 'success' && github.event.workflow_run.event == 'pull_request' && github.event.label.name == 'Action: Deploy PR') || (github.event.action == 'labeled' && github.event.label.name == 'Action: Deploy PR')}}"
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Docker meta
id: meta
uses: docker/metadata-action@v3
with:
images: |
registry.kube.com/scrumlr-server
tags: |
type=ref,event=pr
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
with:
driver: docker
- name: Build and push Server
uses: docker/build-push-action@v2
with:
context: ./server/src
push: true
tags: ${{ steps.meta.outputs.tags }}
cache-from: type=registry,ref=registry.kube.com/scrumlr-server:latest
cache-to: type=inline
deploy-pr:
name: Deploy Feature Branch
runs-on: self-hosted
if: "${{ (github.event.workflow_run.conclusion == 'success' && github.event.workflow_run.event == 'pull_request' && github.event.label.name == 'Action: Deploy PR') || (github.event.action == 'labeled' && github.event.label.name == 'Action: Deploy PR')}}"
needs: [build-frontend, build-server]
steps:
- name: checkout repository
uses: actions/checkout@v2
- name: generate values-dev.yaml
run: |
PR_NUMBER=$(echo $GITHUB_REF | awk 'BEGIN { FS = "/" } ; { print $3 }')
cat > values-dev.yaml << EOF
hostname: $PR_NUMBER.scrumlr.fra.ics.inovex.io
cert:
enabled: true
name: scrumlr-cert-$PR_NUMBER
frontend:
image: registry.kube.com/scrumlr-frontend:$PR_NUMBER
imagePullPolicy: Always
server:
image: registry.kube.com/scrumlr-server:$PR_NUMBER
imagePullPolicy: Always
EOF
- name: deploy pr
run: |
kubectl get po -n scrumlr-$PR_NUMBER | grep 'Running\|Completed' && helm uninstall scrumlr-$PR_NUMBER -n scrumlr-$PR-NUMBER && kubectl delete ns scrumlr-$PR_NUMBER
kubectl wait --for=delete namespace/scrumlr-$PR_NUMBER --timeout=60s
helm dep up deployment/chart/
helm install scrumlr-$PR_NUMBER ./deployment/chart -f values-dev.yaml --namespace scrumlr-$PR_NUMBER --create-namespace
deploy-main:
name: Deploy Main Branch
runs-on: self-hosted
if: ${{ github.event.workflow_run.conclusion == 'success' && github.event.workflow_run.event == 'push'}}
steps:
- name: deploy main
run: |
helm uninstall scrumlr-main --namespace scrumlr-main --wait
helm dep up deployment/chart/
helm install scrumlr-main ./deployment/chart -f ./deployment/chart/env/dev.yaml --namespace scrumlr-main