51 lines
1.8 KiB
YAML
51 lines
1.8 KiB
YAML
name: Build and Publish Docker Image
|
|
description: Define IMAGE_NAME to Git Hub env, based on repository name
|
|
inputs:
|
|
username:
|
|
description: Registry User Name
|
|
required: true
|
|
password:
|
|
description: Registry Password
|
|
required: true
|
|
runs:
|
|
using: composite
|
|
steps:
|
|
- name: Configure SSH
|
|
uses: webfactory/ssh-agent@v0.9.0
|
|
with:
|
|
ssh-private-key: ${{ secrets.SSH_PRIVATE_KEY }}
|
|
|
|
- name: Configure Staging Server
|
|
if: github.ref == 'refs/heads/development'
|
|
shell: sh
|
|
run: echo demo.lhprovedor.com.br,22 > servidores.lst
|
|
|
|
- name: Configure Production Servers
|
|
if: github.ref == 'refs/heads/master'
|
|
shell: sh
|
|
run: |
|
|
export SERVIDORES=`curl ${{ secrets.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;
|