-
Notifications
You must be signed in to change notification settings - Fork 5
/
development-helm.yaml
143 lines (126 loc) · 5.24 KB
/
development-helm.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
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
name: development-helm
on:
push:
branches:
- '*' # matches every branch that doesn't contain a '/'
- '*/*' # matches every branch containing a single '/'
- '**' # matches every branch
- '!main' # excludes main
jobs:
push-to-replicated:
runs-on: ubuntu-22.04
outputs:
channel-slug: ${{ steps.create-release.outputs.channel-slug}}
steps:
- uses: actions/checkout@v3
- name: Define App Version
run: echo "APP_VERSION=0.0.1-${GITHUB_REF_NAME//[^a-zA-Z0-9]/}.${GITHUB_RUN_ID}${GITHUB_RUN_ATTEMPT}" >> $GITHUB_ENV
- name: Define Channel Name
run: echo "CHANNEL_NAME=${{ github.ref_name }}-${GITHUB_RUN_ID}${GITHUB_RUN_ATTEMPT}" >> $GITHUB_ENV
- name: Package Helm Chart for Replicated
id: package-helm-chart
run: |
helm package relmatrix-app -u -d kots \
--app-version=${{ env.APP_VERSION }} \
--version=${{ env.APP_VERSION }}
- name: Update the HelmChart kind
uses: jacobtomlinson/gha-find-replace@v3
with:
include: 'kots/relmatrix-app-chart.yaml'
find: '$VERSION'
replace: ${{ env.APP_VERSION }}
regex: false
- name: Create Replicated Release
id: create-release
uses: replicatedhq/replicated-actions/create-release@v1
with:
app-slug: ${{ secrets.REPLICATED_APP }}
api-token: ${{ secrets.REPLICATED_API_TOKEN }}
yaml-dir: ./kots
promote-channel: ${{ env.CHANNEL_NAME }}
version: ${{ env.APP_VERSION }}
compatibility-matrix:
needs: push-to-replicated
strategy:
fail-fast: false
matrix:
cluster: [ {distribution: kind, version: v1.25.3}, {distribution: kind, version: v1.26.3}]
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3
- name: Define App Version
run: echo "APP_VERSION=0.0.1-${GITHUB_REF_NAME//[^a-zA-Z0-9]/}.${GITHUB_RUN_ID}${GITHUB_RUN_ATTEMPT}" >> $GITHUB_ENV
- name: Create Customer
id: create-customer
uses: replicatedhq/replicated-actions/create-customer@v1
with:
app-slug: ${{ secrets.REPLICATED_APP }}
api-token: ${{ secrets.REPLICATED_API_TOKEN }}
customer-name: ${{ github.ref_name }}-${{ matrix.cluster.distribution }}-${{ matrix.cluster.version }}
channel-slug: ${{ needs.push-to-replicated.outputs.channel-slug }}
customer-email: ${{ github.ref_name }}@example.com
expires-in: 14
- name: Create Cluster
id: create-cluster
uses: replicatedhq/replicated-actions/create-cluster@v1
with:
api-token: ${{ secrets.REPLICATED_API_TOKEN }}
kubernetes-distribution: ${{ matrix.cluster.distribution }}
kubernetes-version: ${{ matrix.cluster.version }}
cluster-name: ${{ github.ref_name }}-${{ matrix.cluster.distribution }}-${{ matrix.cluster.version }}
timeout-minutes: 2
ttl: 10m
tags: |
- key: "department"
value: "engineering"
- name: Deploy the app
uses: replicatedhq/replicated-actions/helm-install@v1
with:
kubeconfig: ${{ steps.create-cluster.outputs.cluster-kubeconfig }}
helm-path: "helm"
registry-username: ${{ github.ref_name }}@example.com
registry-password: ${{ steps.create-customer.outputs.license-id }}
chart: oci://registry.replicated.com/${{ secrets.REPLICATED_APP }}/${{ needs.push-to-replicated.outputs.channel-slug }}/relmatrix-app
name: 'relmatrix-app'
version: ${{ env.APP_VERSION }}
namespace: 'default'
values: |
image:
tag: latest
- name: Run a test
# mask the kubeconfig so it doesn't show up in the logs
run: |
echo "Running a test"
echo "${{ steps.create-cluster.outputs.cluster-kubeconfig }}" > kubeconfig.yaml
sleep 60
kubectl port-forward svc/relmatrix-app --pod-running-timeout=2m --kubeconfig='./kubeconfig.yaml' 8080:80 &
sleep 120
curl -f http://localhost:8080
echo "Test complete"
- name: Remove Cluster
id: remove-cluster
uses: replicatedhq/replicated-actions/remove-cluster@v1
continue-on-error: true # It could be that the cluster is already removed
with:
api-token: ${{ secrets.REPLICATED_API_TOKEN }}
cluster-id: ${{ steps.create-cluster.outputs.cluster-id }}
- name: Archive Customer
id: archive-customer
if: always()
uses: replicatedhq/replicated-actions/archive-customer@v1
with:
api-token: ${{ secrets.REPLICATED_API_TOKEN }}
customer-id: ${{ steps.create-customer.outputs.customer-id }}
cleanup-channel:
needs:
- compatibility-matrix
- push-to-replicated
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3
- name: Archive Replicated Channel
uses: replicatedhq/replicated-actions/archive-channel@v1
with:
app-slug: ${{ secrets.REPLICATED_APP }}
api-token: ${{ secrets.REPLICATED_API_TOKEN }}
channel-slug: ${{ needs.push-to-replicated.outputs.channel-slug }}