Skip to content

feat(api): ✨ Updated create client endpoint #439

feat(api): ✨ Updated create client endpoint

feat(api): ✨ Updated create client endpoint #439

Workflow file for this run

name: Python lint and CI/CD
on: [push, pull_request]
jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: "3.10"
- uses: isort/isort-action@master
with:
sortPaths: "./menuflow"
- uses: psf/black@stable
with:
src: "./menuflow"
version: "22.3.0"
- name: pre-commit
run: |
pip install pre-commit
pre-commit run -av trailing-whitespace
pre-commit run -av end-of-file-fixer
pre-commit run -av check-yaml
pre-commit run -av check-added-large-files
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up Python 3.10
uses: actions/setup-python@v3
with:
python-version: "3.10"
- uses: actions/cache@v3
id: cache
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.*') }}
restore-keys: |
${{ runner.os }}-pip-
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt -r requirements-dev.txt
- name: Run pytest
run: |
pytest -vv
docker:
if: "github.ref_name == 'main'"
runs-on: ubuntu-latest
needs: [lint, test]
environment: deploy
steps:
- name: Checkout code
uses: actions/checkout@v3
-
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
-
name: Login to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
-
name: Build and push
uses: docker/build-push-action@v2
with:
context: .
file: ./Dockerfile
push: true
tags: ${{ vars.MENUFLOW_IMAGE }}
-
# Download updated docker image to testing server
name: Connect to server and update docker image
run: |-
echo "** Connecting to testing server **"
# 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 }}")
# 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
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 "** 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 " >> 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} is not exists'; \
fi;
"
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