CHORE: Adiciona workflows Gitea Actions (deploy-dev e deploy-prod) via rsync

This commit is contained in:
Rafael Alves Lopes 2026-07-21 15:34:56 -03:00
parent fef2065601
commit dff3c7fc9c
2 changed files with 130 additions and 0 deletions

View File

@ -0,0 +1,65 @@
name: Deploy Dev
on:
push:
branches:
- dev
workflow_dispatch:
jobs:
deploy:
name: Deploy para VM Dev
runs-on: self-hosted
env:
DEPLOY_PATH: /opt/omnichannel
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Preflight
shell: bash
run: |
set -euo pipefail
echo "Runner: $(hostname)"
docker --version
docker compose version
psql --version
- name: Verificar secrets obrigatórios
shell: bash
env:
DB_PASSWORD: ${{ secrets.DB_PASSWORD }}
run: |
set -euo pipefail
if [ -z "${DB_PASSWORD:-}" ]; then
echo "Secret DB_PASSWORD não configurado."
exit 1
fi
- name: Sync arquivos para o servidor
shell: bash
run: |
set -euo pipefail
rsync -az --delete \
--exclude='.git/' \
--exclude='.gitea/' \
--exclude='frontend/' \
--exclude='backend/' \
./ "$DEPLOY_PATH"/
- name: Executar migrations
shell: bash
env:
PGPASSWORD: ${{ secrets.DB_PASSWORD }}
run: |
set -euo pipefail
for f in $(ls "$DEPLOY_PATH/database/migrations/"*.sql | sort); do
echo "Aplicando: $(basename "$f")"
psql \
-h ${{ secrets.DB_HOST }} \
-p ${{ secrets.DB_PORT }} \
-U ${{ secrets.DB_USER }} \
-d ${{ secrets.DB_NAME }} \
-f "$f"
done

View File

@ -0,0 +1,65 @@
name: Deploy Prod
on:
push:
branches:
- master
workflow_dispatch:
jobs:
deploy:
name: Deploy para VM Prod
runs-on: self-hosted-prod
env:
DEPLOY_PATH: /opt/omnichannel
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Preflight
shell: bash
run: |
set -euo pipefail
echo "Runner: $(hostname)"
docker --version
docker compose version
psql --version
- name: Verificar secrets obrigatórios
shell: bash
env:
DB_PASSWORD: ${{ secrets.PROD_DB_PASSWORD }}
run: |
set -euo pipefail
if [ -z "${DB_PASSWORD:-}" ]; then
echo "Secret PROD_DB_PASSWORD não configurado."
exit 1
fi
- name: Sync arquivos para o servidor
shell: bash
run: |
set -euo pipefail
rsync -az --delete \
--exclude='.git/' \
--exclude='.gitea/' \
--exclude='frontend/' \
--exclude='backend/' \
./ "$DEPLOY_PATH"/
- name: Executar migrations
shell: bash
env:
PGPASSWORD: ${{ secrets.PROD_DB_PASSWORD }}
run: |
set -euo pipefail
for f in $(ls "$DEPLOY_PATH/database/migrations/"*.sql | sort); do
echo "Aplicando: $(basename "$f")"
psql \
-h ${{ secrets.PROD_DB_HOST }} \
-p ${{ secrets.PROD_DB_PORT }} \
-U ${{ secrets.PROD_DB_USER }} \
-d ${{ secrets.PROD_DB_NAME }} \
-f "$f"
done