This commit is contained in:
53
.github/workflows/pipeline.yml
vendored
Normal file
53
.github/workflows/pipeline.yml
vendored
Normal file
@@ -0,0 +1,53 @@
|
||||
name: CI/CD Pipeline
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [main]
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: home-server
|
||||
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
clean: false
|
||||
|
||||
- name: Login to Docker Hub
|
||||
uses: docker/login-action@v3
|
||||
with:
|
||||
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
||||
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
||||
|
||||
- name: Build and push backend image
|
||||
run: |
|
||||
docker build -q -t alexmickelson/ai-liveview:$GITHUB_RUN_NUMBER .
|
||||
docker push -q alexmickelson/ai-liveview:$GITHUB_RUN_NUMBER
|
||||
|
||||
- name: Deploy to Kubernetes
|
||||
env:
|
||||
KUBECONFIG_CONTENT: ${{ secrets.KUBECONFIG_CONTENT }}
|
||||
AI_TOKEN: ${{ secrets.AI_TOKEN }}
|
||||
INGRESS_HOST: ${{ vars.INGRESS_HOST }}
|
||||
run: |
|
||||
echo "$KUBECONFIG_CONTENT" > /tmp/elixir-kubeconfig.yml
|
||||
export KUBECONFIG=/tmp/elixir-kubeconfig.yml
|
||||
|
||||
kubectl create namespace ai-ha-elixir --dry-run=client -o yaml | kubectl apply -f -
|
||||
|
||||
kubectl get secret ai-ha-elixir-secrets --namespace ai-ha-elixir || \
|
||||
kubectl create secret generic ai-ha-elixir-secrets \
|
||||
--namespace ai-ha-elixir \
|
||||
--from-literal=SECRET_KEY_BASE=$(openssl rand -hex 64) \
|
||||
--from-literal=AI_TOKEN="$AI_TOKEN"
|
||||
|
||||
kubectl create configmap db-schema \
|
||||
--from-file=schema.sql=schema.sql \
|
||||
--namespace ai-ha-elixir \
|
||||
--dry-run=client -o yaml | kubectl apply -f -
|
||||
|
||||
for file in kubernetes/*.yml; do
|
||||
cat "$file" | envsubst | kubectl apply -f -
|
||||
done
|
||||
Reference in New Issue
Block a user