Files
elixir-websocket-testing/.gitea/workflows/pipeline.yml
Alex Mickelson 8abd5b67fe
Some checks failed
CI/CD Pipeline / build (push) Has been cancelled
files
2026-03-03 15:53:46 -07:00

57 lines
1.7 KiB
YAML

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: test
run: |
cd backend
nix-shell -p elixir elixir-ls --run '
MIX_ENV=test mix deps.get --only test
MIX_ENV=test mix test
'
- name: Build and push backend image
run: |
cd client
docker build -t alexmickelson/elixir-demo-frontend:$GITHUB_RUN_NUMBER .
docker push alexmickelson/elixir-demo-frontend:$GITHUB_RUN_NUMBER
cd ../backend
docker build -t alexmickelson/elixir-demo-backend:$GITHUB_RUN_NUMBER .
docker push alexmickelson/elixir-demo-backend:$GITHUB_RUN_NUMBER
- name: Deploy to Kubernetes
env:
KUBECONFIG_CONTENT: ${{ secrets.KUBE_CONFIG_FILE }}
run: |
echo "$KUBECONFIG_CONTENT" > /tmp/elixir-kubeconfig.yml
export KUBECONFIG=/tmp/elixir-kubeconfig.yml
kubectl apply -f kubernetes/0-namespace.yml
kubectl get secret backend-secret --namespace alex-elixir-demo || \
kubectl create secret generic backend-secret \
--namespace alex-elixir-demo \
--from-literal=cookie=$(openssl rand -hex 32)
for file in kubernetes/*.yml; do
cat "$file" | envsubst | kubectl apply -f -
done