All checks were successful
Build and Deploy Frontend / build-and-deploy-frontend (push) Successful in 28s
84 lines
2.5 KiB
YAML
84 lines
2.5 KiB
YAML
name: Build and Deploy Frontend
|
|
|
|
on:
|
|
push:
|
|
branches:
|
|
- master
|
|
|
|
jobs:
|
|
build-and-deploy-frontend:
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
# Checkout
|
|
- name: Checkout
|
|
uses: actions/checkout@v4
|
|
|
|
# Docker smoke test
|
|
- name: Docker smoke test
|
|
run: docker ps -a
|
|
|
|
# Docker login a Gitea registry-be
|
|
- name: Docker login
|
|
run: |
|
|
echo "${{ secrets.REGISTRY_PASSWORD }}" \
|
|
| docker login git.petyi.eu -u "${{ secrets.REGISTRY_USER }}" --password-stdin
|
|
|
|
# Docker build (prod, nginx-es image)
|
|
- name: Docker build (frontend prod)
|
|
run: |
|
|
docker build \
|
|
-t git.petyi.eu/szakdolgozat/frontend:latest \
|
|
--build-arg VITE_BACKEND_API_HOST="http://k8s.petyi.eu" \
|
|
--build-arg VITE_BACKEND_API_PORT="30080" \
|
|
.
|
|
|
|
# Docker push
|
|
- name: Docker push
|
|
run: |
|
|
docker push git.petyi.eu/szakdolgozat/frontend:latest
|
|
|
|
# Kubeconfig beállítása (service accountos kubeconfig)
|
|
- name: Set up kubeconfig
|
|
env:
|
|
KUBECONFIG: /tmp/kubeconfig
|
|
run: |
|
|
echo "${{ secrets.KUBECONFIG_B64 }}" | base64 -d > "$KUBECONFIG"
|
|
echo "==== kubeconfig contexts ===="
|
|
kubectl config get-contexts || true
|
|
|
|
# Kubernetes smoke test
|
|
- name: Kubernetes smoke test
|
|
env:
|
|
KUBECONFIG: /tmp/kubeconfig
|
|
run: |
|
|
kubectl cluster-info
|
|
kubectl -n szakdolgozat get pods
|
|
|
|
# Rollout restart a frontend deploymentre
|
|
- name: Rollout restart frontend deployment
|
|
env:
|
|
KUBECONFIG: /tmp/kubeconfig
|
|
run: |
|
|
kubectl -n szakdolgozat rollout restart deployment/telefonkonyv-frontend
|
|
kubectl -n szakdolgozat rollout status deployment/telefonkonyv-frontend --timeout=60s
|
|
|
|
# Frontend URL kiírása + Step Summary
|
|
- name: Show Frontend URL
|
|
env:
|
|
KUBECONFIG: /tmp/kubeconfig
|
|
run: |
|
|
FRONTEND_NODEPORT=$(kubectl -n szakdolgozat get svc telefonkonyv-frontend -o jsonpath='{.spec.ports[0].nodePort}')
|
|
URL="http://k8s.petyi.eu:${FRONTEND_NODEPORT}"
|
|
echo "Frontend URL: ${URL}"
|
|
|
|
# Ha a runner biztosítja a step summary-t (Gitea act_runner szokta),
|
|
# akkor írjuk bele oda is:
|
|
if [ -n "${GITHUB_STEP_SUMMARY}" ]; then
|
|
{
|
|
echo "### Frontend deployment"
|
|
echo ""
|
|
echo "- URL: ${URL}"
|
|
} >> "${GITHUB_STEP_SUMMARY}"
|
|
fi
|