-
Notifications
You must be signed in to change notification settings - Fork 1
102 lines (87 loc) · 3 KB
/
ci.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
name: Continuous Integration
on:
push:
branches:
- "main"
tags:
- "*"
env:
KUBECONFIG: .kube/config
KUBECONFIG_FILE: ${{ secrets.KUBECONFIG }}
jobs:
build:
name: "Build Image"
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
- id: generate-image-tag
name: Generate Image Tag
run: |
head_ref="${GITHUB_HEAD_REF//\//-}"
ref_name="${head_ref:-${GITHUB_REF_NAME/main/latest}}"
echo "imageTag=${ref_name#v}" >> $GITHUB_ENV
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Set up JDK
uses: actions/setup-java@v2
with:
distribution: 'temurin'
java-version: '17'
- name: Run tests
run: ./gradlew test
- name: Build with Gradle
run: ./gradlew clean build
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Build and push
uses: docker/build-push-action@v5
with:
context: ./
file: ./Dockerfile
push: true
tags: |
ghcr.io/${{ github.repository }}:${{ env.imageTag }}
ghcr.io/${{ github.repository }}:${{ github.event.pull_request.head.sha || github.sha }}
deploy_main:
needs: build
if: github.ref == 'refs/heads/main'
runs-on: ubuntu-latest
steps:
- id: generate-image-tag
name: Generate Image Tag
run: |
head_ref="${GITHUB_HEAD_REF//\//-}"
ref_name="${head_ref:-${GITHUB_REF_NAME/main/latest}}"
echo "imageTag=${ref_name#v}" >> $GITHUB_ENV
- uses: actions/checkout@v2
- name: Set up Kubernetes config
run: |
mkdir -p .kube
echo "${{ secrets.KUBECONFIG }}" > $KUBECONFIG
- name: Create Kubernetes secret for ONTOPORTAL_APIKEY
run: |
kubectl create secret generic ontoportal-secret \
--from-literal=ONTOPORTAL_APIKEY=${{ secrets.ONTOPORTAL_APIKEY }} \
--namespace='ts4nfdi' \
--dry-run=client -o yaml | kubectl apply -f -
- name: Deploy to Kubernetes
uses: stefanprodan/kube-tools@v1
with:
helmv3: 3.12.0
command: |
kubectl get nodes
helmv3 repo add api-gateway-deployment https://ts4nfdi.github.io/api-gateway-deployment/
helmv3 repo update
helmv3 upgrade ts4nfdi \
--install \
--namespace='ts4nfdi' \
--set-json='ingress.dns="ts4nfdi-api-gateway.prod.km.k8s.zbmed.de"' \
--set-json='images.frontend="ghcr.io/${{ github.repository }}:${{ github.event.pull_request.head.sha || github.sha }}"' \
--set-json='ingress.enableSSL="true"' \
--set-json='ingress.certIssuer="letsencrypt-prod"' \
api-gateway-deployment/api-gateway