Update .gitea/workflows/main.yml

This commit is contained in:
2026-03-23 17:32:07 +00:00
parent f4a394f0e2
commit 07e91e788d

View File

@@ -1,86 +1,86 @@
name: Reusable Deploy to Pterodactyl (Gitea) name: Reusable Deploy to Pterodactyl (Gitea)
on: on:
workflow_call: workflow_call:
inputs: inputs:
build-run-id: build-run-id:
description: 'ID da execução que gerou o artefato' description: 'ID da execução que gerou o artefato'
required: true required: true
type: string type: string
artifact-name: artifact-name:
description: 'Nome do artefato' description: 'Nome do artefato'
required: true required: true
type: string type: string
jobs: jobs:
deploy: deploy:
runs-on: ubuntu-latest runs-on: ubuntu-latest
env: env:
REMOTE_TMP_DIR: "/root/tmp-plugins" REMOTE_TMP_DIR: "/root/tmp-plugins"
PTERO_VOLUME_PATH: "/var/lib/pterodactyl/volumes" PTERO_VOLUME_PATH: "/var/lib/pterodactyl/volumes"
strategy: strategy:
fail-fast: false fail-fast: false
matrix: matrix:
include: include:
- node_name: "Node 1" - node_name: "Node 1"
host: '193.123.103.129' host: '193.123.103.129'
port: '2123' port: '22'
password: 'Senha_Do_Node_1_Aqui' # Altere aqui password: 'VoF)1}=gO!PWMe#GU;6lD='8' # Altere aqui
- node_name: "Node 2" - node_name: "Node 3"
host: '204.216.129.233' host: '148.116.109.49'
port: '2123' port: '22'
password: 'Senha_Do_Node_2_Aqui' # Altere aqui password: 'iuhSIUH17g!#iu!g@#!edkjqag@#' # Altere aqui
steps: steps:
- name: 📥 Baixar artefatos - name: 📥 Baixar artefatos
uses: actions/download-artifact@v4 uses: actions/download-artifact@v4
with: with:
name: ${{ inputs.artifact-name }} name: ${{ inputs.artifact-name }}
path: ./builds path: ./builds
run-id: ${{ inputs.build-run-id }} run-id: ${{ inputs.build-run-id }}
- name: 🚀 Deploy para ${{ matrix.node_name }} (${{ matrix.host }}) - name: 🚀 Deploy para ${{ matrix.node_name }} (${{ matrix.host }})
shell: bash shell: bash
run: | run: |
set -x set -x
shopt -s globstar shopt -s globstar
# Instala sshpass para lidar com a senha no comando # Instala sshpass para lidar com a senha no comando
sudo apt-get update && sudo apt-get install -y sshpass sudo apt-get update && sudo apt-get install -y sshpass
echo "🔧 Criando diretório temporário remoto..." echo "🔧 Criando diretório temporário remoto..."
sshpass -p "${{ matrix.password }}" \ sshpass -p "${{ matrix.password }}" \
ssh -o StrictHostKeyChecking=no -p ${{ matrix.port }} \ ssh -o StrictHostKeyChecking=no -p ${{ matrix.port }} \
root@${{ matrix.host }} "mkdir -p ${{ env.REMOTE_TMP_DIR }}" root@${{ matrix.host }} "mkdir -p ${{ env.REMOTE_TMP_DIR }}"
for jar_file in builds/**/*.jar; do for jar_file in builds/**/*.jar; do
if [ -f "$jar_file" ]; then if [ -f "$jar_file" ]; then
PLUGIN_NAME=$(basename "$jar_file") PLUGIN_NAME=$(basename "$jar_file")
REMOTE_JAR_PATH="${{ env.REMOTE_TMP_DIR }}/${PLUGIN_NAME}" REMOTE_JAR_PATH="${{ env.REMOTE_TMP_DIR }}/${PLUGIN_NAME}"
echo "📤 Enviando ${PLUGIN_NAME}..." echo "📤 Enviando ${PLUGIN_NAME}..."
sshpass -p "${{ matrix.password }}" \ sshpass -p "${{ matrix.password }}" \
sftp -o StrictHostKeyChecking=no -P ${{ matrix.port }} \ sftp -o StrictHostKeyChecking=no -P ${{ matrix.port }} \
root@${{ matrix.host }} <<EOF root@${{ matrix.host }} <<EOF
put "${jar_file}" "${REMOTE_JAR_PATH}" put "${jar_file}" "${REMOTE_JAR_PATH}"
bye bye
EOF EOF
echo "🔐 Atualizando containers e reiniciando..." echo "🔐 Atualizando containers e reiniciando..."
sshpass -p "${{ matrix.password }}" \ sshpass -p "${{ matrix.password }}" \
ssh -o StrictHostKeyChecking=no -p ${{ matrix.port }} \ ssh -o StrictHostKeyChecking=no -p ${{ matrix.port }} \
root@${{ matrix.host }} " root@${{ matrix.host }} "
set -ex set -ex
find '${{ env.PTERO_VOLUME_PATH }}' -type f -path '*/plugins/${PLUGIN_NAME}' | while read -r plugin_path; do find '${{ env.PTERO_VOLUME_PATH }}' -type f -path '*/plugins/${PLUGIN_NAME}' | while read -r plugin_path; do
echo \"-> Atualizando em: \${plugin_path}\" echo \"-> Atualizando em: \${plugin_path}\"
cp '${REMOTE_JAR_PATH}' \"\${plugin_path}\" cp '${REMOTE_JAR_PATH}' \"\${plugin_path}\"
server_id=\$(echo \"\${plugin_path}\" | cut -d'/' -f6) server_id=\$(echo \"\${plugin_path}\" | cut -d'/' -f6)
echo \"-> Reiniciando container: \${server_id}\" echo \"-> Reiniciando container: \${server_id}\"
docker container restart \"\${server_id}\" || true docker container restart \"\${server_id}\" || true
done done
rm -f '${REMOTE_JAR_PATH}' rm -f '${REMOTE_JAR_PATH}'
" "
fi fi
done done
echo "🌟 Node ${{ matrix.host }} finalizado!" echo "🌟 Node ${{ matrix.host }} finalizado!"