From e43c81f3aa1d14a132bf32299338507a6ae46ae8 Mon Sep 17 00:00:00 2001 From: egalvis Date: Wed, 15 Nov 2023 17:52:55 -0500 Subject: [PATCH 1/2] =?UTF-8?q?ci(CI/CD):=20=F0=9F=92=9A=20fix=20CI/CD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/main.yml | 40 ++++++++++++++++++++++++++++---------- 1 file changed, 30 insertions(+), 10 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index e1aa389..a7e3a84 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -79,33 +79,53 @@ jobs: - 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) menuflow_service="${stack_name}_${service}-menuflow" - echo " >> Removing the service if it exists" + + echo " >> Remove the service if exists" ssh -tt ${{ secrets.HOST_TESTING }} " \ 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 From 160fc3db48553e27de6b2d2d61fd631f5344db36 Mon Sep 17 00:00:00 2001 From: egalvis Date: Wed, 15 Nov 2023 17:54:01 -0500 Subject: [PATCH 2/2] =?UTF-8?q?ci(CI/CD):=20=F0=9F=92=9A=20fix=20CI/CD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/main.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index a7e3a84..edb1d3a 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -77,7 +77,6 @@ jobs: tags: ${{ vars.MENUFLOW_IMAGE }} - - name: Run Bash script # Download updated docker image to testing server name: Connect to server and update docker image run: |-