juntekim.com/.github/workflows/deploy-postgres.yml
2025-12-13 15:46:00 +00:00

59 lines
1.7 KiB
YAML
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

name: Deploy DB Infrastructure
on:
push:
branches:
- main
jobs:
deploy:
runs-on: mealcraft-runners
steps:
- name: Checkout repo
uses: actions/checkout@v4
# Install kubectl
- name: Install kubectl
run: |
sudo apt-get update
sudo apt-get install -y curl ca-certificates
curl -LO "https://dl.k8s.io/release/$(curl -sL https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl"
sudo install -m 0755 kubectl /usr/local/bin/kubectl
# Configure kubeconfig (ARC in-cluster)
- name: Configure kubeconfig
run: |
KUBE_HOST="https://$KUBERNETES_SERVICE_HOST:$KUBERNETES_SERVICE_PORT"
SA_TOKEN=$(cat /var/run/secrets/kubernetes.io/serviceaccount/token)
CA_CERT=/var/run/secrets/kubernetes.io/serviceaccount/ca.crt
NAMESPACE=$(cat /var/run/secrets/kubernetes.io/serviceaccount/namespace)
kubectl config set-cluster microk8s \
--server="$KUBE_HOST" \
--certificate-authority="$CA_CERT"
kubectl config set-credentials runner \
--token="$SA_TOKEN"
kubectl config set-context runner-context \
--cluster=microk8s \
--user=runner \
--namespace="$NAMESPACE"
kubectl config use-context runner-context
# 1⃣ Secrets
- name: Apply DB secrets
run: |
kubectl apply -f db/k8s/secrets/
# 2⃣ PostgreSQL
- name: Deploy Postgres
run: |
kubectl apply -f db/k8s/postgres/
# 3⃣ Backups (CronJob)
- name: Deploy Postgres backups
run: |
kubectl apply -f db/k8s/backups/