omnichannel-frontend/.gitea/workflows/deploy-dev.yml

72 lines
1.8 KiB
YAML

name: Deploy Dev — Frontend
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
- name: Verificar secrets obrigatórios
shell: bash
env:
ENV_DEV: ${{ secrets.ENV_DEV }}
run: |
set -euo pipefail
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