Files
catalog26/.gitea/workflows/demo.yaml
Wesley Cho c6c2426d3a
Some checks failed
Build and Deploy / build-and-push (pull_request) Successful in 28s
Build and Deploy / deploy-to-k8s (pull_request) Has been cancelled
fix k8s workflow
2026-02-01 22:07:43 -08:00

65 lines
1.9 KiB
YAML

name: Build and Deploy
run-name: ${{ github.actor }} is building and pushing 🚀
on:
pull_request:
branches:
- master
env:
REGISTRY: git.chopark.home
IMAGE: ${{ gitea.repository }} # wesscho/catalog26
DEPLOYMENT_NAME: catalog26-deployment # my deployment name
CONTAINER_NAME: catalog26 # <-- MUST match spec.template.spec.containers[].name
NAMESPACE: catalog # my namespace
jobs:
build-and-push:
runs-on: ubuntu-latest
steps:
- name: Check out repository code
uses: actions/checkout@v4
- name: Login to Gitea Registry
# We use single quotes around the secret to prevent shell interpretation
# and the VM IP to bypass the 'server' DNS issue.
run: |
echo '${{ secrets.REGISTRY_TOKEN }}' | \
docker login ${{ env.REGISTRY }} \
--username ${{ gitea.actor }} \
--password-stdin
- name: Build and Push Docker Image
run: |
docker build -t ${{ env.REGISTRY }}/${{ env.IMAGE }}:latest .
docker push ${{ env.REGISTRY }}/${{ env.IMAGE }}:latest
- name: List files in the repository
run: ls ${{ github.workspace }}
- run: echo "🍏 Build and Push status is ${{ job.status }}."
deploy-to-k8s:
needs: build-and-push
runs-on: ubuntu-latest
container:
image: bitnami/kubectl:latest
steps:
- name: Set Kubeconfig
run: |
echo "${{ secrets.KUBE_CONFIG }}" > kubeconfig.yaml
- name: Update Deployment Image
env:
KUBECONFIG: kubeconfig.yaml
run: |
set -euo pipefail
kubectl set image \
"deployment/${DEPLOYMENT_NAME}" \
"${CONTAINER_NAME}=${REGISTRY}/${IMAGE}:latest" \
-n "${NAMESPACE}"
# Optional: wait for rollout to complete (recommended)
kubectl rollout status "deployment/${DEPLOYMENT_NAME}" -n "${NAMESPACE}"