-
Notifications
You must be signed in to change notification settings - Fork 0
156 lines (138 loc) · 5.17 KB
/
pr.yml
File metadata and controls
156 lines (138 loc) · 5.17 KB
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
144
145
146
147
148
149
150
151
152
153
154
155
156
name: PR
on:
pull_request:
branches: [main]
permissions:
contents: read
packages: write
jobs:
build-and-release:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
outputs:
version-label: ${{ env.VERSION_LABEL }}
chart-version: ${{ env.CHART_VERSION }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log in to ghcr.io
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Set version label
run: |
echo "VERSION_LABEL=pr-${{ github.event.pull_request.number }}-${{ github.run_number }}" >> $GITHUB_ENV
echo "CHART_VERSION=0.0.${{ github.run_number }}" >> $GITHUB_ENV
- name: Build and push image
uses: docker/build-push-action@v6
with:
context: .
push: true
platforms: linux/amd64
tags: |
ghcr.io/aa-replicated/gameshelf:pr-${{ github.event.pull_request.number }}
ghcr.io/aa-replicated/gameshelf:pr-${{ github.event.pull_request.number }}-${{ github.run_number }}
- name: Package Helm chart
run: |
helm dependency update chart/gameshelf
helm package chart/gameshelf \
--version ${{ env.CHART_VERSION }} \
--app-version ${{ env.VERSION_LABEL }} \
--destination release/
- name: Copy Replicated configs
run: |
cp .replicated release/
cp embedded-cluster-config.yaml release/
sed "s/chartVersion: .*/chartVersion: \"${{ env.CHART_VERSION }}\"/" helmchart.yaml > release/helmchart.yaml
cp kots-config.yaml release/
cp kots-app.yaml release/
- name: Create Replicated release
id: create-release
uses: replicatedhq/replicated-actions/create-release@v1
with:
app-slug: gameshelf
api-token: ${{ secrets.REPLICATED_API_TOKEN }}
yaml-dir: release/
promote-channel: Unstable
version: ${{ env.CHART_VERSION }}
compatibility-matrix:
needs: build-and-release
runs-on: ubuntu-latest
steps:
- name: Create customer
id: create-customer
uses: replicatedhq/replicated-actions/create-customer@v1
with:
app-slug: gameshelf
api-token: ${{ secrets.REPLICATED_API_TOKEN }}
customer-name: pr-${{ github.event.pull_request.number }}-k3s-1.35
channel-slug: unstable
customer-email: ci-pr-${{ github.event.pull_request.number }}@example.com
expires-in: 1
is-kots-install-enabled: "false"
- name: Create cluster
id: create-cluster
uses: replicatedhq/replicated-actions/create-cluster@v1
with:
api-token: ${{ secrets.REPLICATED_API_TOKEN }}
kubernetes-distribution: k3s
kubernetes-version: "1.35"
cluster-name: gameshelf-pr-${{ github.event.pull_request.number }}
timeout-minutes: 5
ttl: 30m
- name: Deploy chart
uses: replicatedhq/replicated-actions/helm-install@v1
with:
kubeconfig: ${{ steps.create-cluster.outputs.cluster-kubeconfig }}
helm-path: helm
registry-username: ci-pr-${{ github.event.pull_request.number }}@example.com
registry-password: ${{ steps.create-customer.outputs.license-id }}
chart: oci://registry.replicated.com/gameshelf/unstable/gameshelf
name: gameshelf
version: ${{ needs.build-and-release.outputs.chart-version }}
namespace: gameshelf
values: |
adminSecret: ci-test-secret
imageProxy:
host: ""
postgresql:
enabled: true
image:
registry: docker.io
volumePermissions:
image:
registry: docker.io
redis:
enabled: true
image:
registry: docker.io
- name: Health check
env:
KUBECONFIG_CONTENT: ${{ steps.create-cluster.outputs.cluster-kubeconfig }}
run: |
echo "$KUBECONFIG_CONTENT" > /tmp/kubeconfig.yaml
kubectl wait --for=condition=ready pod -l app.kubernetes.io/name=gameshelf \
-n gameshelf --timeout=120s --kubeconfig=/tmp/kubeconfig.yaml
kubectl port-forward svc/gameshelf 8080:80 -n gameshelf \
--kubeconfig=/tmp/kubeconfig.yaml &
sleep 5
curl -f http://localhost:8080/healthz
- name: Remove cluster
if: always()
uses: replicatedhq/replicated-actions/remove-cluster@v1
continue-on-error: true
with:
api-token: ${{ secrets.REPLICATED_API_TOKEN }}
cluster-id: ${{ steps.create-cluster.outputs.cluster-id }}
- name: 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 }}