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