Skip to content

ci: add GitHub Actions pipeline for test and homologacao deploys - #17

Merged
lbrunofidelis merged 5 commits into
devfrom
feat/github-actions-cicd
Sep 3, 2026
Merged

lbrunofidelis merged 5 commits into
devfrom
feat/github-actions-cicd

Conversation

@lbrunofidelis

@lbrunofidelis lbrunofidelis commented Aug 25, 2026 •

Copy link
Copy Markdown
Collaborator

Adds continuous integration and deployment for both instances.

Pull requests are validated on GitHub-hosted runners only. Deploys run on a self-hosted runner, so nothing triggered by a pull request can reach it, and the pipeline needs no secrets.

A push to dev deploys to the test instance automatically. Homologacao is deployed manually from the Actions tab, with an option to merge dev into homologacao first.

The frontend build runs in CI and is shipped as an artifact. The deploy script preserves the per-instance local config, reinstalls dependencies when the lockfile moves, backs up Mongo before migrating, and rolls the code back if the health check fails.

@lbrunofidelis
lbrunofidelis force-pushed the feat/github-actions-cicd branch from 7439b00 to 79076ce Compare August 26, 2026 01:36
@lbrunofidelis
lbrunofidelis force-pushed the feat/github-actions-cicd branch from 79076ce to 88037c2 Compare August 26, 2026 02:23
The repository is public, so service names, tree locations and the backup
directory no longer belong in the script. Read them from a settings file
on the runner instead, and drop the runner label from the workflow.
@lbrunofidelis

Copy link
Copy Markdown
Collaborator Author

Atualização: dados do servidor saíram do repositório

Como os repositórios são públicos, tudo que descreve a máquina de deploy saiu do script e passou a vir de um arquivo não rastreado no runner.

Antes (versionado e público): nomes de serviço do gerenciador de processos, layout de diretórios das instâncias, diretório de backup, label do runner.

Agora: o script recebe só --instance teste|opas e lê o resto de ~/.config/godata/deploy.env, cujo modelo vazio está em ops/deploy.env.example. A localização pode ser trocada por GODATA_DEPLOY_ENV.

O que continua no repositório é fato de git, não de servidor: o mapa teste -> dev e opas -> homologacao, que já estava público nos gatilhos do workflow.

O runs-on virou [self-hosted], sem label específico. Se um dia existir mais de um runner, o label volta como variável de repositório em vez de literal.

Passo novo de instalação

Uma vez no runner, antes do primeiro deploy:

install -Dm600 ops/deploy.env.example ~/.config/godata/deploy.env
# preencher GODATA_ROOT, GODATA_BACKUP_ROOT, GODATA_SERVICE_TESTE, GODATA_SERVICE_OPAS

Validado

Cenário Esperado Resultado
arquivo de settings ausente erro nomeando o caminho erro nomeando o caminho
settings sem o serviço da instância erro nomeando a variável erro nomeando a variável
settings completo, instância inexistente erro de diretório erro de diretório
--instance producao recusado recusado

bash -n limpo.

Limite honesto

Isso tira as informações do repositório. O runner self-hosted continua publicando o nome da máquina e o nome do runner no cabeçalho do log de cada execução, e log de repositório público é público. Se esconder isso também for requisito, o caminho é o deploy por pull: o servidor consulta o GitHub e roda um script que mora só nele, sem runner registrado.

mongodump, npm and pm2 write progress to stderr, which was reaching the
workflow log together with paths, the database name and the service name.
Send it to a file on the host instead, and stop printing the settings path.
Both scripts truncated the same file, so the second deploy of an instance erased the output of the first.
@lbrunofidelis
lbrunofidelis merged commit b100874 into dev Sep 3, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant