Files
tamagotchi-service/.gitea/workflows/deploy.yaml
T
khalil 12a97b18bc
CI/CD Pipeline / test (push) Successful in 9s
CI/CD Pipeline / build-push-deploy (push) Failing after 3s
ci: fix docker login and image push
2026-07-04 18:28:58 +00:00

68 lines
3.3 KiB
YAML

name: CI/CD Pipeline
on:
push:
branches:
- main
paths-ignore:
- 'api-deployment.yaml'
- 'frontend-deployment.yaml'
env:
GIT_SSL_NO_VERIFY: "true"
NODE_TLS_REJECT_UNAUTHORIZED: "0"
jobs:
test:
runs-on: ubuntu-latest
steps:
- name: Checkout Code
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
- name: Install dependencies and test API
working-directory: ./api
run: npm install && node -c server.js
build-push-deploy:
runs-on: ubuntu-latest
needs: test
permissions:
packages: write
contents: write
env:
DOCKER_HOST: tcp://localhost:2375
steps:
- name: Checkout Code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Log in to Gitea Container Registry
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login git.88.96.58.76.nip.io -u ${{ github.actor }} --password-stdin || echo "${{ secrets.GITHUB_TOKEN }}" | docker login gitea-http.gitea.svc.cluster.local:3000 -u ${{ github.actor }} --password-stdin
- name: Build and Push API
run: |
docker build --network=host -t git.88.96.58.76.nip.io/${{ github.repository_owner }}/tamagotchi-api:${{ github.sha }} ./api
docker push git.88.96.58.76.nip.io/${{ github.repository_owner }}/tamagotchi-api:${{ github.sha }} || (docker tag git.88.96.58.76.nip.io/${{ github.repository_owner }}/tamagotchi-api:${{ github.sha }} gitea-http.gitea.svc.cluster.local:3000/${{ github.repository_owner }}/tamagotchi-api:${{ github.sha }} && docker push gitea-http.gitea.svc.cluster.local:3000/${{ github.repository_owner }}/tamagotchi-api:${{ github.sha }})
- name: Build and Push Frontend
run: |
docker build --network=host -t git.88.96.58.76.nip.io/${{ github.repository_owner }}/tamagotchi-frontend:${{ github.sha }} ./frontend
docker push git.88.96.58.76.nip.io/${{ github.repository_owner }}/tamagotchi-frontend:${{ github.sha }} || (docker tag git.88.96.58.76.nip.io/${{ github.repository_owner }}/tamagotchi-frontend:${{ github.sha }} gitea-http.gitea.svc.cluster.local:3000/${{ github.repository_owner }}/tamagotchi-frontend:${{ github.sha }} && docker push gitea-http.gitea.svc.cluster.local:3000/${{ github.repository_owner }}/tamagotchi-frontend:${{ github.sha }})
- name: Update Kubernetes Manifests
run: |
sed -i "s|image: .*tamagotchi-api:.*|image: git.88.96.58.76.nip.io/${{ github.repository_owner }}/tamagotchi-api:${{ github.sha }}|g" api-deployment.yaml
sed -i "s|image: .*tamagotchi-frontend:.*|image: git.88.96.58.76.nip.io/${{ github.repository_owner }}/tamagotchi-frontend:${{ github.sha }}|g" frontend-deployment.yaml
- name: Commit and Push changes
run: |
git config --global user.name "gitea-actions[bot]"
git config --global user.email "gitea-actions@gitea.local"
git remote set-url origin http://${{ github.actor }}:${{ secrets.GITHUB_TOKEN }}@gitea-http.gitea.svc.cluster.local:3000/${{ github.repository }}
git add api-deployment.yaml frontend-deployment.yaml
git commit -m "chore: deploy version ${{ github.sha }} [skip ci]" || echo "No changes to commit"
git push origin main