GIT_PUSH - Enviar Commits para Repositório Remoto
O que é este Node?
O GIT_PUSH é o node responsável por enviar commits locais para o repositório remoto. Ele executa o comando git push para sincronizar mudanças locais com o servidor Git.
Por que este Node existe?
Depois de fazer commits localmente, precisamos enviá-los ao repositório remoto para compartilhar com a equipe e fazer backup. O GIT_PUSH existe para:
- Compartilhamento: Disponibilizar mudanças para toda a equipe
- Backup: Garantir que mudanças estão seguras no servidor remoto
- Deploy: Trigger automático de pipelines CI/CD
- Sincronização: Manter repositório remoto atualizado
Como funciona internamente?
Quando o GIT_PUSH é executado, o sistema:
- Valida repositório: Verifica se o path é um repositório Git válido
- Determina branch: Usa branch especificada ou 'main' como padrão
- Substitui variáveis: Aplica variáveis do contexto
- Executa push: Roda
git push origin [branch] - Se erro: Lança exceção (sem permissão, conflitos, etc)
- Se sucesso: Retorna confirmação do push
Código interno (git.executor.ts:118-122):
private async push(repoPath: string, branch: string, context: ExecutionContext): Promise<any> {
const branchName = branch ? this.replaceVariables(branch, context.variables) : 'main';
const output = await this.execGit(repoPath, `push origin ${branchName}`, context);
return { output, pushed: true };
}
Quando você DEVE usar este Node?
Use GIT_PUSH sempre que precisar de enviar commits locais para remoto:
Casos de uso
- Deploy automatizado: "Após commit, fazer push e trigger de deploy"
- Backup automatizado: "Todo commit deve ser enviado imediatamente ao remoto"
- Sincronização de equipe: "Disponibilizar mudanças para outros desenvolvedores"
- CI/CD Pipeline: "Push para trigger testes e build automatizado"
Quando NÃO usar GIT_PUSH
- Sem commits locais: Nada para enviar
- Branch desatualizada: Faça pull primeiro para evitar conflitos
- Mudanças não testadas: Teste antes de push
Parâmetros Detalhados
repositoryPath (string, obrigatório)
O que é: Caminho absoluto para o repositório Git local de onde os commits serão enviados.
Padrão: Nenhum (obrigatório informar)
Flow completo para testar:
{
"name": "Teste Git Push - Repository Path",
"nodes": [
{
"id": "start_1",
"type": "start",
"position": { "x": 100, "y": 100 },
"data": { "label": "Início" }
},
{
"id": "variable_1",
"type": "variable",
"position": { "x": 300, "y": 100 },
"data": {
"label": "Path",
"parameters": {
"variable": "repo_path",
"value": "/var/www/projeto"
}
}
},
{
"id": "git_push_1",
"type": "git",
"position": { "x": 500, "y": 100 },
"data": {
"label": "Push",
"operation": "push",
"repositoryPath": "{{repo_path}}",
"branch": "main",
"responseVariable": "push_result"
}
},
{
"id": "message_1",
"type": "message",
"position": { "x": 700, "y": 100 },
"data": {
"label": "Confirmar",
"parameters": {
"message": "Push realizado!\n{{push_result.output}}"
}
}
},
{
"id": "end_1",
"type": "end",
"position": { "x": 900, "y": 100 },
"data": { "label": "Fim" }
}
],
"edges": [
{ "source": "start_1", "target": "variable_1" },
{ "source": "variable_1", "target": "git_push_1" },
{ "source": "git_push_1", "target": "message_1" },
{ "source": "message_1", "target": "end_1" }
]
}
Teste: Execute o flow. Sistema enviará commits para o remoto.
branch (string, opcional)
O que é: Nome da branch que será enviada ao repositório remoto.
Padrão: "main" (se não especificado)
Flow completo para testar:
{
"name": "Teste Git Push - Branch",
"nodes": [
{
"id": "start_1",
"type": "start",
"position": { "x": 100, "y": 100 },
"data": { "label": "Início" }
},
{
"id": "input_1",
"type": "input",
"position": { "x": 300, "y": 100 },
"data": {
"label": "Nome da Branch",
"parameters": {
"message": "Digite o nome da branch:",
"variable": "branch_name"
}
}
},
{
"id": "git_push_1",
"type": "git",
"position": { "x": 500, "y": 100 },
"data": {
"label": "Push Branch",
"operation": "push",
"repositoryPath": "/var/www/app",
"branch": "{{branch_name}}",
"responseVariable": "push_result"
}
},
{
"id": "message_1",
"type": "message",
"position": { "x": 700, "y": 100 },
"data": {
"label": "Resultado",
"parameters": {
"message": "Branch {{branch_name}} enviada com sucesso!"
}
}
},
{
"id": "end_1",
"type": "end",
"position": { "x": 900, "y": 100 },
"data": { "label": "Fim" }
}
],
"edges": [
{ "source": "start_1", "target": "input_1" },
{ "source": "input_1", "target": "git_push_1" },
{ "source": "git_push_1", "target": "message_1" },
{ "source": "message_1", "target": "end_1" }
]
}
Teste: Digite "develop" quando solicitado. Sistema enviará a branch develop.
responseVariable (string, opcional)
O que é: Nome da variável onde o resultado do push será armazenado.
Padrão: Nenhum (resultado não é armazenado)
Estrutura do retorno:
{
"output": "To github.com:user/repo.git\n abc1234..def5678 main -> main",
"pushed": true
}
Flow completo para testar:
{
"name": "Teste Git Push - Response Variable",
"nodes": [
{
"id": "start_1",
"type": "start",
"position": { "x": 100, "y": 100 },
"data": { "label": "Início" }
},
{
"id": "git_push_1",
"type": "git",
"position": { "x": 300, "y": 100 },
"data": {
"label": "Push com Variável",
"operation": "push",
"repositoryPath": "/var/www/app",
"branch": "main",
"responseVariable": "push_info"
}
},
{
"id": "condition_1",
"type": "condition",
"position": { "x": 500, "y": 100 },
"data": {
"label": "Verificar Push",
"parameters": {
"condition": "{{push_info.pushed}} === true"
}
}
},
{
"id": "message_success",
"type": "message",
"position": { "x": 700, "y": 50 },
"data": {
"label": "Sucesso",
"parameters": {
"message": "Push bem-sucedido!\n{{push_info.output}}"
}
}
},
{
"id": "message_error",
"type": "message",
"position": { "x": 700, "y": 150 },
"data": {
"label": "Erro",
"parameters": {
"message": "Falha no push"
}
}
},
{
"id": "end_1",
"type": "end",
"position": { "x": 900, "y": 100 },
"data": { "label": "Fim" }
}
],
"edges": [
{ "source": "start_1", "target": "git_push_1" },
{ "source": "git_push_1", "target": "condition_1" },
{ "source": "condition_1", "target": "message_success", "label": "true" },
{ "source": "condition_1", "target": "message_error", "label": "false" },
{ "source": "message_success", "target": "end_1" },
{ "source": "message_error", "target": "end_1" }
]
}
Teste: Execute o flow. Sistema verifica se push foi bem-sucedido.
Parâmetros
| Campo | Tipo | Obrigatório | Descrição |
|---|---|---|---|
| operation | string | Sim | Deve ser "push" |
| repositoryPath | string | Sim | Caminho do repositório local |
| branch | string | Não | Nome da branch (padrão: "main") |
| responseVariable | string | Não | Variável para armazenar resultado |
Exemplo 1: Push Automatizado Após Commit
Objetivo: Fazer commit e push automático de mudanças
JSON para Importar
{
"name": "Commit e Push Automático",
"nodes": [
{
"id": "start_1",
"type": "start",
"position": { "x": 100, "y": 100 },
"data": { "label": "Início" }
},
{
"id": "git_add_1",
"type": "git",
"position": { "x": 300, "y": 100 },
"data": {
"label": "Add Files",
"operation": "add",
"repositoryPath": "/var/www/docs",
"pathsToAdd": ".",
"responseVariable": "add_result"
}
},
{
"id": "git_commit_1",
"type": "git",
"position": { "x": 500, "y": 100 },
"data": {
"label": "Commit",
"operation": "commit",
"repositoryPath": "/var/www/docs",
"message": "docs: update documentation",
"responseVariable": "commit_result"
}
},
{
"id": "git_push_1",
"type": "git",
"position": { "x": 700, "y": 100 },
"data": {
"label": "Push",
"operation": "push",
"repositoryPath": "/var/www/docs",
"branch": "main",
"responseVariable": "push_result"
}
},
{
"id": "message_1",
"type": "message",
"position": { "x": 900, "y": 100 },
"data": {
"label": "Sucesso",
"parameters": {
"message": "Documentação atualizada e enviada ao remoto com sucesso!"
}
}
},
{
"id": "end_1",
"type": "end",
"position": { "x": 1100, "y": 100 },
"data": { "label": "Fim" }
}
],
"edges": [
{ "source": "start_1", "target": "git_add_1" },
{ "source": "git_add_1", "target": "git_commit_1" },
{ "source": "git_commit_1", "target": "git_push_1" },
{ "source": "git_push_1", "target": "message_1" },
{ "source": "message_1", "target": "end_1" }
]
}
Saída esperada:
Sistema: Documentação atualizada e enviada ao remoto com sucesso!
Exemplo 2: Push para Múltiplas Branches
Objetivo: Enviar commits para diferentes branches baseado em ambiente
JSON para Importar
{
"name": "Push Multi-Branch",
"nodes": [
{
"id": "start_1",
"type": "start",
"position": { "x": 100, "y": 100 },
"data": { "label": "Início" }
},
{
"id": "input_1",
"type": "input",
"position": { "x": 300, "y": 100 },
"data": {
"label": "Ambiente",
"parameters": {
"message": "Digite o ambiente (dev/staging/prod):",
"variable": "ambiente"
}
}
},
{
"id": "switch_1",
"type": "switch",
"position": { "x": 500, "y": 100 },
"data": {
"label": "Selecionar Branch",
"parameters": {
"variable": "ambiente",
"cases": [
{ "value": "dev", "output": "develop" },
{ "value": "staging", "output": "staging" },
{ "value": "prod", "output": "main" }
]
},
"outputVariable": "target_branch"
}
},
{
"id": "git_push_1",
"type": "git",
"position": { "x": 700, "y": 100 },
"data": {
"label": "Push",
"operation": "push",
"repositoryPath": "/var/www/app",
"branch": "{{target_branch}}",
"responseVariable": "push_result"
}
},
{
"id": "message_1",
"type": "message",
"position": { "x": 900, "y": 100 },
"data": {
"label": "Confirmação",
"parameters": {
"message": "Push realizado para {{target_branch}} (ambiente {{ambiente}})"
}
}
},
{
"id": "end_1",
"type": "end",
"position": { "x": 1100, "y": 100 },
"data": { "label": "Fim" }
}
],
"edges": [
{ "source": "start_1", "target": "input_1" },
{ "source": "input_1", "target": "switch_1" },
{ "source": "switch_1", "target": "git_push_1" },
{ "source": "git_push_1", "target": "message_1" },
{ "source": "message_1", "target": "end_1" }
]
}
Saída esperada:
Usuário: prod
Sistema: Push realizado para main (ambiente prod)
Exemplo 3: Push com Validação Prévia
Objetivo: Verificar se há commits antes de fazer push
JSON para Importar
{
"name": "Push com Validação",
"nodes": [
{
"id": "start_1",
"type": "start",
"position": { "x": 100, "y": 100 },
"data": { "label": "Início" }
},
{
"id": "git_status_1",
"type": "git",
"position": { "x": 300, "y": 100 },
"data": {
"label": "Verificar Status",
"operation": "status",
"repositoryPath": "/var/www/projeto",
"responseVariable": "status_result"
}
},
{
"id": "condition_1",
"type": "condition",
"position": { "x": 500, "y": 100 },
"data": {
"label": "Tem Commits?",
"parameters": {
"condition": "{{status_result.status}}.includes('Your branch is ahead')"
}
}
},
{
"id": "git_push_1",
"type": "git",
"position": { "x": 700, "y": 50 },
"data": {
"label": "Push",
"operation": "push",
"repositoryPath": "/var/www/projeto",
"branch": "main",
"responseVariable": "push_result"
}
},
{
"id": "message_pushed",
"type": "message",
"position": { "x": 900, "y": 50 },
"data": {
"label": "Sucesso",
"parameters": {
"message": "Commits enviados ao remoto com sucesso!"
}
}
},
{
"id": "message_no_commits",
"type": "message",
"position": { "x": 700, "y": 150 },
"data": {
"label": "Sem Commits",
"parameters": {
"message": "Não há commits locais para enviar."
}
}
},
{
"id": "end_1",
"type": "end",
"position": { "x": 1100, "y": 100 },
"data": { "label": "Fim" }
}
],
"edges": [
{ "source": "start_1", "target": "git_status_1" },
{ "source": "git_status_1", "target": "condition_1" },
{ "source": "condition_1", "target": "git_push_1", "label": "true" },
{ "source": "condition_1", "target": "message_no_commits", "label": "false" },
{ "source": "git_push_1", "target": "message_pushed" },
{ "source": "message_pushed", "target": "end_1" },
{ "source": "message_no_commits", "target": "end_1" }
]
}
Saída esperada (com commits):
Sistema: Commits enviados ao remoto com sucesso!
Saída esperada (sem commits):
Sistema: Não há commits locais para enviar.
Resposta do Node
{
"output": "To github.com:user/repo.git\n abc1234..def5678 main -> main",
"pushed": true
}
Boas Práticas
✅ SIM:
- Verifique status antes de push
- Use branches específicas para ambientes
- Configure SSH keys para autenticação
- Faça pull antes de push para evitar conflitos
- Use mensagens de commit descritivas
- Valide que há commits antes de push
❌ NÃO:
- Não faça push --force sem necessidade
- Não envie código não testado
- Não faça push direto para main sem revisão
- Não ignore erros de push
- Não exponha credenciais em logs
- Não faça push durante processos críticos
Dicas
💡 Dica 1: Use GIT_STATUS antes do push para verificar se há commits locais
💡 Dica 2: Combine com WEBHOOK para notificar equipe sobre push
💡 Dica 3: Use RETRY node para tentar novamente em caso de falha de rede
💡 Dica 4: Configure hooks pré-push para validação automática
💡 Dica 5: Use tags após push de releases importantes
Próximo Node
→ GIT_COMMIT - Criar commit antes de push → GIT_STATUS - Verificar status antes de push → GIT_CREATE_TAG - Criar tag após push de release