Skip to content

Commit

Permalink
Merge pull request #54 from iKonoTelecomunicaciones/48-fix-cicd
Browse files Browse the repository at this point in the history
ci(CI/CD): 💚 fix CI/CD
  • Loading branch information
egalvis39 committed Nov 15, 2023
2 parents 36a0aa3 + a812762 commit 1428a35
Showing 1 changed file with 28 additions and 10 deletions.
38 changes: 28 additions & 10 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -77,19 +77,35 @@ jobs:
tags: ${{ vars.MENUFLOW_IMAGE }}

-
name: Run Bash script
# Download updated docker image to testing server
run: |
name: Connect to server and update docker image
run: |-
echo "** Connecting to testing server **"
apt-get update -qq
apt-get install -qq openssh-client
# Update the apt package index
sudo apt-get update -qq
# If ssh-agent does not exist, install openssh-client
which ssh-agent || ( sudo apt-get install openssh-client )
# Start the ssh-agent in the background
eval $(ssh-agent -s)
# Add the SSH key stored in SSH_PRIVATE_KEY variable to the agent store
ssh-add <(echo "${{ secrets.SSH_PRIVATE_KEY }}")
mkdir -p ~/.ssh
# Create the SSH config directory
mkdir -vp ~/.ssh
# Disable StrictHostKeyChecking ask in SSH config
[[ -e ~/.ssh ]] && echo -e "Host *\n\tStrictHostKeyChecking no\n\n" > ~/.ssh/config
echo "** Downloading updated Docker image ${{ vars.MENUFLOW_IMAGE }} **"
ssh -tt ${{ secrets.HOST_TESTING }} "echo '** Connected **'"
echo "** Download updated docker image **"
# Download updated docker image to testing server
ssh -tt ${{ secrets.HOST_TESTING }} "docker pull ${{ vars.MENUFLOW_IMAGE }}"
echo "** Updating menuflow image in registered domains **"
for domain in ${{ vars.DOMAINS }}; do
echo "** Update menuflow image in registered domains **"
for domain in ${{ vars.DOMAINS }}; do
echo " >> Setting service variables"
stack_name=$(echo ${domain} | tr -d '.')
service=$(echo ${domain} | cut -d '.' -f1)
Expand All @@ -99,12 +115,14 @@ jobs:
if docker service ps ${menuflow_service}; then \
docker service rm ${menuflow_service}; \
else \
echo 'The service ${menuflow_service} does not exist'; \
echo 'The service ${menuflow_service} is not exists'; \
fi;
"
echo " >> Deploying the service"
echo " >> Deploy the service"
docker_compose_file="/mnt/shared/matrix/${domain}/docker-compose.yml"
ssh -tt ${{ secrets.HOST_TESTING }} " \
docker-compose -f ${docker_compose_file} config | \
docker stack deploy -c - ${stack_name};
"
done

0 comments on commit 1428a35

Please sign in to comment.