feat: add Gitea workflows for blue-green deployment and rollback functionality.
Deploy Next.js via SSH / deploy (push) Successful in 8s
Details
Deploy Next.js via SSH / deploy (push) Successful in 8s
Details
This commit is contained in:
parent
b953113f3c
commit
db7cea2759
|
|
@ -7,15 +7,24 @@ jobs:
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v3
|
||||||
|
|
||||||
- name: Deploy via SSH
|
- name: Blue-Green Deploy via SSH
|
||||||
uses: appleboy/ssh-action@master
|
uses: appleboy/ssh-action@master
|
||||||
with:
|
with:
|
||||||
host: 10.1.1.124
|
host: 10.1.1.124
|
||||||
username: juru
|
username: juru
|
||||||
key: ${{ secrets.SSH_PRIVATE_KEY }}
|
key: ${{ secrets.SSH_PRIVATE_KEY }}
|
||||||
script: |
|
script: |
|
||||||
cd /home/juru/Portal-dias-rota
|
RELEASE_NAME=release-$(date +%Y%m%d%H%M%S)
|
||||||
git pull origin main
|
RELEASE_PATH=/home/juru/apps/releases/$RELEASE_NAME
|
||||||
npm install --legacy-peer-deps
|
|
||||||
|
git clone http://10.1.1.124:3000/joelson/Portal-dias-rota.git $RELEASE_PATH
|
||||||
|
cd $RELEASE_PATH
|
||||||
|
|
||||||
|
npm install
|
||||||
npm run build
|
npm run build
|
||||||
pm2 restart portal-dias-rota || pm2 start npm --name "portal-dias-rota" -- start
|
|
||||||
|
ln -sfn $RELEASE_PATH /home/juru/apps/current
|
||||||
|
|
||||||
|
pm2 reload portal-dias-rota || pm2 start /home/juru/apps/current/ecosystem.config.js
|
||||||
|
|
||||||
|
ls -dt /home/juru/apps/releases/* | tail -n +5 | xargs rm -rf
|
||||||
|
|
@ -1,25 +1,26 @@
|
||||||
name: Manual Rollback
|
name: Rollback para Versão Anterior
|
||||||
on:
|
on:
|
||||||
workflow_dispatch: # Permite rodar manualmente pela interface do Gitea
|
workflow_dispatch: # Isso faz aparecer um botão "Run Workflow" no Gitea
|
||||||
inputs:
|
|
||||||
commit_hash:
|
|
||||||
description: 'Hash do commit para retornar'
|
|
||||||
required: true
|
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
rollback:
|
rollback:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- name: Execute Rollback via SSH
|
- name: Reverter Link Simbólico
|
||||||
uses: appleboy/ssh-action@master
|
uses: appleboy/ssh-action@master
|
||||||
with:
|
with:
|
||||||
host: 10.1.1.124
|
host: 10.1.1.124
|
||||||
username: juru
|
username: juru
|
||||||
key: ${{ secrets.SSH_PRIVATE_KEY }}
|
key: ${{ secrets.SSH_PRIVATE_KEY }}
|
||||||
script: |
|
script: |
|
||||||
cd /home/juru/Portal-dias-rota
|
PREVIOUS_RELEASE=$(ls -dt /home/juru/apps/releases/* | sed -n '2p')
|
||||||
git fetch origin
|
|
||||||
git reset --hard ${{ github.event.inputs.commit_hash }}
|
if [ -z "$PREVIOUS_RELEASE" ]; then
|
||||||
npm install --production
|
echo "Erro: Nenhuma versão anterior encontrada!"
|
||||||
npm run build
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
ln -sfn $PREVIOUS_RELEASE /home/juru/apps/current
|
||||||
|
|
||||||
pm2 reload portal-dias-rota
|
pm2 reload portal-dias-rota
|
||||||
|
echo "Rollback para $PREVIOUS_RELEASE concluído com sucesso!"
|
||||||
Loading…
Reference in New Issue