56 lines
2 KiB
YAML
56 lines
2 KiB
YAML
name: Build and Publish Docker Image
|
|
description: Define IMAGE_NAME to Git Hub env, based on repository name
|
|
inputs:
|
|
ssh-private-key:
|
|
description: SSH Private Key
|
|
required: true
|
|
url-servidores:
|
|
description: URL to download servers list
|
|
required: false
|
|
default: https://gerencia.lhprovedor.com.br/servidores
|
|
staging-server:
|
|
description: Staging Server url,ssh-port.
|
|
required: false
|
|
default: demo.lhprovedor.com.br,22
|
|
runs:
|
|
using: composite
|
|
steps:
|
|
- name: Configure SSH
|
|
uses: webfactory/ssh-agent@v0.9.0
|
|
with:
|
|
ssh-private-key: ${{ inputs.ssh-private-key }}
|
|
|
|
- name: Configure Staging Server
|
|
if: github.ref == 'refs/heads/development'
|
|
shell: sh
|
|
run: echo ${{ inputs.staging-server }} > servidores.lst
|
|
|
|
- name: Configure Production Servers
|
|
if: github.ref == 'refs/heads/master' || github.ref == 'refs/heads/main'
|
|
shell: sh
|
|
run: |
|
|
export SERVIDORES=`curl ${{ inputs.url-servidores }}`
|
|
echo "Leandro Servidores: $SERVIDORES"
|
|
echo $SERVIDORES >> servidores.lst
|
|
- name: deploy
|
|
shell: sh
|
|
run: |
|
|
for i in `cat servidores.lst`; do
|
|
IP=`echo $i | cut -d , -f 1`;
|
|
PORTA=`echo $i | cut -d , -f 2`;
|
|
echo "----------------------------------------------------------------------------------------"
|
|
echo "-- Syncing $IP:$PORTA"
|
|
ssh root@$IP -p $PORTA -o StrictHostKeyChecking=no -t "
|
|
cd /lh && docker image prune --force &&
|
|
docker-compose pull --quiet lhisp-dbupdater &&
|
|
docker-compose pull --quiet $BITBUCKET_REPO_SLUG &&
|
|
docker-compose up -d --remove-orphans --force-recreate lhisp-dbupdater
|
|
docker-compose up -d --remove-orphans --force-recreate ${{ env.IMAGE_NAME }}
|
|
" > $IP-$PORTA.log 2>&1 &
|
|
done;
|
|
wait
|
|
for i in `ls *.log`; do
|
|
echo "------------------------------------";
|
|
echo "Arquivo: $i";
|
|
cat $i;
|
|
done;
|