Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci(CI/CD): 馃挌 fix CI/CD #54

Merged
merged 3 commits into from
Nov 15, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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