Files
tamagotchi-service/.gitea/workflows/ci.yaml
T
khalil c989d2c189
CI/CD Pipeline / quality-and-security (push) Successful in 9s
CI/CD Pipeline / build-and-push (push) Failing after 4s
CI/CD Pipeline / deploy (push) Has been skipped
ci: use gitea-http-ci ClusterIP service for reliable clone
2026-07-02 07:33:33 +00:00

71 lines
2.4 KiB
YAML

name: CI/CD Pipeline
on:
push:
branches:
- main
jobs:
quality-and-security:
runs-on: ubuntu-latest
container:
image: node:20-alpine
steps:
- name: Checkout Code
run: |
apk add --no-cache git
git clone http://gitea-http-ci.gitea.svc.cluster.local:3000/${{ gitea.repository }}.git .
git checkout ${{ gitea.sha }}
- name: Install dependencies (API)
run: cd api && npm install
- name: Code Quality (API Syntax Check)
run: cd api && node -c server.js
- name: Security Test (npm audit)
run: cd api && npm audit --audit-level=low || true
build-and-push:
needs: quality-and-security
runs-on: ubuntu-latest
steps:
- name: Checkout Code
run: |
git clone http://gitea-http-ci.gitea.svc.cluster.local:3000/${{ gitea.repository }}.git .
git checkout ${{ gitea.sha }}
- name: Build API Docker Image
run: docker build -t git.88.96.58.76.nip.io/khalil/tamagotchi-api:${{ gitea.sha }} ./api
- name: Build Frontend Docker Image
run: docker build -t git.88.96.58.76.nip.io/khalil/tamagotchi-frontend:${{ gitea.sha }} ./frontend
- name: Login to Gitea Registry
run: echo "${{ secrets.GITEA_TOKEN }}" | docker login git.88.96.58.76.nip.io -u ${{ gitea.repository_owner }} --password-stdin
- name: Push API Image
run: docker push git.88.96.58.76.nip.io/khalil/tamagotchi-api:${{ gitea.sha }}
- name: Push Frontend Image
run: docker push git.88.96.58.76.nip.io/khalil/tamagotchi-frontend:${{ gitea.sha }}
deploy:
needs: build-and-push
runs-on: ubuntu-latest
steps:
- name: Clone GitOps Repo
run: |
git clone http://gitea-http-ci.gitea.svc.cluster.local:3000/khalil/tamagotchi-gitops.git .
git config user.name "Gitea Actions"
git config user.email "actions@gitea.local"
- name: Update ArgoCD Manifest
run: |
sed -i "s|image: .*tamagotchi-api:.*|image: git.88.96.58.76.nip.io/khalil/tamagotchi-api:${{ gitea.sha }}|g" k8s.yaml
sed -i "s|image: .*tamagotchi-frontend:.*|image: git.88.96.58.76.nip.io/khalil/tamagotchi-frontend:${{ gitea.sha }}|g" k8s.yaml
- name: Push Updated Manifest
run: |
git add k8s.yaml
git diff --cached --quiet && echo "No changes to commit" || (git commit -m "chore: Update image tags to ${{ gitea.sha }} [skip ci]" && git push)