ci: restrict workflow triggers to main branch only
Some checks failed
Build (develop) / Promote (main) / build-and-push-deploy (push) Failing after 1m15s
Some checks failed
Build (develop) / Promote (main) / build-and-push-deploy (push) Failing after 1m15s
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
name: Build (develop) / Promote (main)
|
||||
on:
|
||||
push:
|
||||
branches: [main, develop, homolog]
|
||||
branches: [main]
|
||||
|
||||
jobs:
|
||||
build-and-push-deploy:
|
||||
@@ -15,15 +15,29 @@ jobs:
|
||||
- name: Build and Push
|
||||
run: |
|
||||
REGISTRY="git.simplifiquehc.com.br"
|
||||
# Forçamos o caminho completo em minúsculas
|
||||
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
|
||||
|
||||
# Build com ambas as tags
|
||||
docker build -t "$IMAGE_NAME:$SHA_TAG" -t "$IMAGE_NAME:latest" .
|
||||
|
||||
# Push de ambas para garantir que o 'latest' exista no registro
|
||||
docker push "$IMAGE_NAME:$SHA_TAG"
|
||||
docker push "$IMAGE_NAME:latest"
|
||||
|
||||
- name: Update Manifest and Push to Git
|
||||
run: |
|
||||
SHA_TAG=$(echo ${{ gitea.sha }} | cut -c1-7)
|
||||
IMAGE_NAME="git.simplifiquehc.com.br/simplifique/vendaweb-api"
|
||||
|
||||
# 1. Altera a imagem no arquivo YAML (ajuste o caminho 'deploy-api.yaml' se necessário)
|
||||
# O comando procura a linha 'image:' e substitui pela nova tag do SHA
|
||||
sed -i "s|image: $IMAGE_NAME:.*|image: $IMAGE_NAME:$SHA_TAG|g" deploy-api.yaml
|
||||
|
||||
# 2. Configura o Git para commitar a alteração
|
||||
git config --global user.name "Gitea Action"
|
||||
git config --global user.email "actions@simplifiquehc.com.br"
|
||||
|
||||
# 3. Faz o commit e push da alteração no manifesto
|
||||
git add deploy-api.yaml
|
||||
git commit -m "chore: update image tag to $SHA_TAG [skip ci]"
|
||||
git push origin main
|
||||
Reference in New Issue
Block a user