CHORE: Atualiza workflows Gitea Actions para deploy via rsync com checkout e ENV_DEV secret

This commit is contained in:
Rafael Alves Lopes 2026-07-21 15:35:50 -03:00
parent faa03f80cf
commit 0928d8d0d3
2 changed files with 128 additions and 10 deletions

View File

@ -1,24 +1,71 @@
name: Deploy Dev name: Deploy Dev — Frontend
on: on:
push: push:
branches: branches:
- dev - dev
workflow_dispatch:
jobs: jobs:
deploy: deploy:
name: Deploy para VM Dev
runs-on: self-hosted runs-on: self-hosted
env:
DEPLOY_PATH: /opt/omnichannel
steps: steps:
- name: Atualizar código na VM Dev - name: Checkout
run: | uses: actions/checkout@v4
cd /opt/omnichannel/frontend
git pull origin dev
- name: Copiar env - name: Preflight
shell: bash
run: | run: |
cp /home/desenvolvimento/.envs/omnichannel/frontend.env.development /opt/omnichannel/frontend/.env.development set -euo pipefail
echo "Runner: $(hostname)"
docker --version
docker compose version
- name: Rebuild container - name: Verificar secrets obrigatórios
shell: bash
env:
ENV_DEV: ${{ secrets.ENV_DEV }}
run: | run: |
cd /opt/omnichannel set -euo pipefail
docker compose up -d --build frontend if [ -z "${ENV_DEV:-}" ]; then
echo "Secret ENV_DEV não configurado. Adicione o conteúdo completo do .env.development em Settings > Actions > Secrets."
exit 1
fi
- name: Escrever .env.development
shell: bash
env:
ENV_DEV: ${{ secrets.ENV_DEV }}
run: |
set -euo pipefail
printf '%s\n' "$ENV_DEV" > "$DEPLOY_PATH/frontend/.env.development"
chmod 600 "$DEPLOY_PATH/frontend/.env.development"
- name: Sync código
shell: bash
run: |
set -euo pipefail
LOCK="/tmp/omnichannel-frontend-dev.lock"
(
flock -n 9 || { echo "Deploy já em andamento. Tente novamente em instantes."; exit 1; }
rsync -az --delete \
--exclude='.git/' \
--exclude='.gitea/' \
--exclude='.env*' \
--exclude='node_modules/' \
--exclude='dist/' \
./ "$DEPLOY_PATH/frontend/"
) 9>"$LOCK"
- name: Build e reiniciar container
shell: bash
run: |
set -euo pipefail
cd "$DEPLOY_PATH"
docker compose build frontend
docker compose up -d frontend

View File

@ -0,0 +1,71 @@
name: Deploy Prod — Frontend
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
- name: Verificar secrets obrigatórios
shell: bash
env:
ENV_PROD: ${{ secrets.ENV_PROD }}
run: |
set -euo pipefail
if [ -z "${ENV_PROD:-}" ]; then
echo "Secret ENV_PROD não configurado."
exit 1
fi
- name: Escrever .env.production
shell: bash
env:
ENV_PROD: ${{ secrets.ENV_PROD }}
run: |
set -euo pipefail
printf '%s\n' "$ENV_PROD" > "$DEPLOY_PATH/frontend/.env.production"
chmod 600 "$DEPLOY_PATH/frontend/.env.production"
- name: Sync código
shell: bash
run: |
set -euo pipefail
LOCK="/tmp/omnichannel-frontend-prod.lock"
(
flock -n 9 || { echo "Deploy já em andamento. Tente novamente em instantes."; exit 1; }
rsync -az --delete \
--exclude='.git/' \
--exclude='.gitea/' \
--exclude='.env*' \
--exclude='node_modules/' \
--exclude='dist/' \
./ "$DEPLOY_PATH/frontend/"
) 9>"$LOCK"
- name: Build e reiniciar container
shell: bash
run: |
set -euo pipefail
cd "$DEPLOY_PATH"
docker compose build frontend
docker compose up -d frontend