name: Build (develop) / Promote (main) on: push: branches: [main] jobs: build-and-push-deploy: runs-on: ubuntu-latest steps: - name: Checkout uses: actions/checkout@v4 with: fetch-depth: 0 - name: Build and Push run: | REGISTRY="git.simplifiquehc.com.br" IMAGE_NAME="$REGISTRY/simplifique/vendaweb-api" SHA_TAG=$(echo ${{ gitea.sha }} | cut -c1-7) echo "${{ secrets.K8S }}" | docker login "$REGISTRY" -u "${{ gitea.actor }}" --password-stdin docker build -t "$IMAGE_NAME:$SHA_TAG" -t "$IMAGE_NAME:latest" . docker push "$IMAGE_NAME:$SHA_TAG" docker push "$IMAGE_NAME:latest" - name: Update Kubernetes Manifest run: | SHA_TAG=$(echo ${{ gitea.sha }} | cut -c1-7) IMAGE_NAME="git.simplifiquehc.com.br/simplifique/vendaweb-api" sed -i "s|image: $IMAGE_NAME:.*|image: $IMAGE_NAME:$SHA_TAG|g" k8s/base/deployment.yaml git config --global user.name "Gitea Action" git config --global user.email "actions@simplifiquehc.com.br" git add k8s/base/deployment.yaml git commit -m "chore: update image tag to $SHA_TAG [skip ci]" git push origin main