Update maint.yml #8
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Create/Update Test Environment | |
on: | |
push: | |
branches: | |
- master | |
jobs: | |
deploy: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v3 | |
- name: SSH and Deploy | |
uses: appleboy/ssh-action@v1.2.2 | |
with: | |
host: ${{ secrets.TEST_SERVER_IP }} | |
username: ${{ secrets.SSH_USERNAME }} | |
key: ${{ secrets.SSHT_PRIVATE_KEY }} | |
script: | | |
cd /tmp/WSS-site/ | |
# Pull latest changes | |
git pull origin master | |
# Stop and remove old test containers | |
docker ps -a | grep -E "backend-test|frontend-test|postgres-test" | awk '{print $1}' | xargs -r docker rm -f | |
# rm compose.yaml front-compose.yaml | |
# cp compose.yaml compose.yaml | |
# cp front-compose.yaml front-compose.yaml | |
# Remove old test network and volume | |
docker network rm app-network-test || true | |
docker volume rm postgres-data-test || true | |
# Create a test network | |
docker network create app-network-test | |
# Create a test database volume from the production volume | |
docker volume create postgres-data-test | |
# cp -r /var/lib/docker/volumes/wss-site_postgres-data/_data /var/lib/docker/volumes/postgres-data-test/_data | |
echo $PWD | |
ls | |
# Modify backend docker-compose.yml for test environment | |
sed -i 's/container_name: backend/container_name: backend-test/' compose.yaml | |
sed -i 's/container_name: postgres/container_name: postgres-test/' compose.yaml | |
sed -i 's/8000:8000/18000:8000/' compose.yaml | |
sed -i 's/app-network/app-network-test/' compose.yaml | |
sed -i 's/postgres-data:/postgres-data-test:/' compose.yaml | |
sed -i '/postgres-data-test:/,/driver: local/ {s/driver: local/external: true/;}' compose.yaml | |
sed -i '/app-network-test:/,/driver: bridge/ {s/driver: bridge/external: true/;}' compose.yaml | |
# Remove all payment-related sections from the backend compose file | |
sed -i '/payment/,+9d' compose.yaml | |
# Modify frontend docker-compose.yml for test environment | |
sed -i 's/container_name: frontend/container_name: frontend-test/' front-compose.yaml | |
sed -i 's/3000:3000/13000:3000/' front-compose.yaml | |
sed -i 's/app-network/app-network-test/' front-compose.yaml | |
sed -i '/app-network-test:/,/driver: bridge/ {s/driver: bridge/external: true/;}' front-compose.yaml | |
# Update API_ORIGIN in .env.frontend for test environment | |
sed -i 's|API_ORIGIN=http://91.107.181.116:8000|API_ORIGIN=http://91.107.181.116:18000|' .env.frontend | |
sed -i 's|API_ORIGIN=http://91.107.181.116:8000|API_ORIGIN=http://91.107.181.116:18000|' ./frontend/.env | |
cd backend | |
# docker build -t wss:back . | |
# Build the backend and frontend images | |
docker build -t wss:backend backend | |
# docker build -t wss:frontend frontend | |
cd .. | |
# Start the test containers | |
docker-compose up -d |