Files
tamagotchi-service/.gitea/workflows/ci.yaml
T
khalil f94aa15f60
CI/CD Pipeline / quality-and-security (push) Successful in 8s
CI/CD Pipeline / build-and-push (push) Failing after 13s
CI/CD Pipeline / deploy (push) Has been skipped
ci: add --network host to docker build to fix MTU/ECONNRESET
2026-07-02 09:07:36 +00:00

79 lines
2.7 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
container:
image: docker:24-cli
options: -v /var/run/docker.sock:/var/run/docker.sock
steps:
- name: Install git
run: apk add --no-cache git
- 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 --network host -t git.88.96.58.76.nip.io/khalil/tamagotchi-api:${{ gitea.sha }} ./api
- name: Build Frontend Docker Image
run: docker build --network host -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
container:
image: alpine/git: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)