Repository navigation
101 lines (88 loc) · 3.27 KB
/
Copy pathdeploy.yml
File metadata and controls
101 lines (88 loc) · 3.27 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
name: deploy
on:
push:
branches: [main]
permissions:
contents: read
concurrency:
group: server-deploy-main
cancel-in-progress: false
jobs:
build-and-deploy:
runs-on: ubuntu-latest
timeout-minutes: 20
permissions:
contents: read
packages: write
steps:
- name: Checkout repository
uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4
- name: Configure kubectl
env:
KUBE_CONFIG_B64: ${{ secrets.KUBE_CONFIG }}
run: |
set -euo pipefail
if [ -z "$KUBE_CONFIG_B64" ]; then
echo "::error::KUBE_CONFIG secret이 비어 있습니다."
exit 1
fi
mkdir -p ~/.kube
printf '%s' "$KUBE_CONFIG_B64" | base64 -d > ~/.kube/config
chmod 600 ~/.kube/config
- name: Check secret prerequisites
run: |
set -euo pipefail
kubectl cluster-info
for name in postgres-secret server-env; do
if ! kubectl -n fowoco get secret/"$name" >/dev/null 2>&1; then
echo "::error::secret/$name이 없습니다. infra Wiki의 Deployment Guide를 참고해 먼저 생성해 주세요 (Secret은 git으로 관리하지 않음)."
exit 1
fi
done
- name: Checkout infra manifests
uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4
with:
repository: fowoco/infra
path: infra
- name: Bootstrap k8s resources
run: |
set -euo pipefail
kubectl apply -f infra/k8s/00-namespace.yaml
kubectl apply -f infra/k8s/01-postgres.yaml
kubectl apply -f infra/k8s/02-server.yaml
kubectl -n fowoco rollout status statefulset/postgres --timeout=60s
- name: Login to GHCR
uses: docker/login-action@c94ce9fb468520275223c153574b00df6fe4bcc9 # v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build, test and push image
uses: docker/build-push-action@10e90e3645eae34f1e60eeb005ba3a3d33f178e8 # v6
with:
context: .
push: true
tags: |
ghcr.io/fowoco/server:latest
ghcr.io/fowoco/server:${{ github.sha }}
- name: Rollout
run: |
set -euo pipefail
kubectl -n fowoco set image deployment/server \
server=ghcr.io/fowoco/server:${{ github.sha }} \
--record=false
kubectl -n fowoco rollout status deployment/server --timeout=180s
- name: Smoke health endpoints
run: |
set -euo pipefail
kubectl -n fowoco exec deployment/server -- \
curl --fail --silent --show-error http://127.0.0.1:8080/actuator/health/readiness
kubectl -n fowoco exec deployment/server -- \
curl --fail --silent --show-error http://127.0.0.1:8080/health
- name: Rollout diagnostics
if: failure()
run: |
kubectl -n fowoco get pods -o wide || true
kubectl -n fowoco describe deployment/server || true
kubectl -n fowoco logs deployment/server --tail=150 --all-containers || true
kubectl -n fowoco get events --sort-by=.lastTimestamp | tail -n 80 || true