# ============================================================================= # Gitea Actions Workflow - node-bugado # ============================================================================= # # Pipeline GitOps: # 1. Build: Constrói imagem Docker e faz push para Gitea Registry # 2. Deploy: Atualiza manifests no repo GitOps (ArgoCD faz sync) # # Secrets necessários (Repository → Settings → Actions → Secrets): # - REGISTRY_TOKEN: Token para push no Gitea Container Registry # - DEPLOY_KEY: Chave SSH privada para push no repo GitOps # - GITOPS_REPO: URL SSH do repo GitOps (ex: git@gitea.kube.quest:user/gitops-demo.git) # # ============================================================================= name: Build and Deploy on: push: branches: [main] env: REGISTRY: gitea.kube.quest IMAGE_NAME: ${{ gitea.repository }} jobs: build: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - name: Login to Gitea Registry run: | echo "${{ secrets.REGISTRY_TOKEN }}" | docker login ${{ env.REGISTRY }} \ -u ${{ gitea.actor }} --password-stdin - name: Build and push run: | echo "Building ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ github.sha }}" docker build \ -t ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ github.sha }} \ -t ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest \ . docker push ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ github.sha }} docker push ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest deploy: runs-on: ubuntu-latest needs: build steps: - name: Setup SSH run: | mkdir -p ~/.ssh echo "${{ secrets.DEPLOY_KEY }}" > ~/.ssh/id_ed25519 chmod 600 ~/.ssh/id_ed25519 ssh-keyscan gitea.kube.quest >> ~/.ssh/known_hosts 2>/dev/null || true - name: Update GitOps repo run: | git config --global user.email "ci@gitea.kube.quest" git config --global user.name "Gitea CI" git clone ${{ secrets.GITOPS_REPO }} gitops cd gitops SHORT_SHA=$(echo "${{ github.sha }}" | cut -c1-8) if [ -f apps/node-bugado/deployment.yaml ]; then sed -i "s|image:.*node-bugado.*|image: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ github.sha }}|g" apps/node-bugado/deployment.yaml git add apps/node-bugado/deployment.yaml git commit -m "deploy: node-bugado ${SHORT_SHA} [skip ci]" git push echo "GitOps repo updated" else echo "WARNING: apps/node-bugado/deployment.yaml not found" exit 1 fi