Change signature #4
This file contains hidden or 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: CI/CD | |
| on: | |
| push: | |
| branches: | |
| - main | |
| jobs: | |
| CD: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v2 | |
| - name: Deploy | |
| uses: appleboy/ssh-action@master | |
| with: | |
| host: ${{ secrets.SERVER_SSH_HOST }} | |
| username: ${{ secrets.SERVER_SSH_USER }} | |
| password: ${{ secrets.SERVER_SSH_PASSWORD }} | |
| port: 22 | |
| script: | | |
| set -e | |
| DEPLOY_DIR="/home/${{ github.repository_owner }}/${{ github.event.repository.name }}" | |
| CONTAINER_NAME="${{ github.event.repository.name }}" | |
| echo "[1/7] Ensure deployment directory exists: $DEPLOY_DIR" | |
| mkdir -p "$DEPLOY_DIR" | |
| cd "$DEPLOY_DIR" | |
| if [ ! -d ".git" ]; then | |
| echo "[3/7] Clone repository if not exists" | |
| git clone git@github.com:uzdevid/${{ github.event.repository.name }} ./ | |
| echo "[4/7] Copy template files" | |
| cp /home/template/entrypoint.sh $DEPLOY_DIR/entrypoint.sh | |
| cp /home/template/Dockerfile $DEPLOY_DIR/Dockerfile | |
| cp /home/template/rr.exe $DEPLOY_DIR/rr.exe | |
| cp /home/template/supervisord.conf $DEPLOY_DIR/supervisord.conf | |
| else | |
| echo "[4/7] Copy template files" | |
| cp /home/template/entrypoint.sh $DEPLOY_DIR/entrypoint.sh | |
| cp /home/template/Dockerfile $DEPLOY_DIR/Dockerfile | |
| cp /home/template/rr.exe $DEPLOY_DIR/rr.exe | |
| cp /home/template/supervisord.conf $DEPLOY_DIR/supervisord.conf | |
| echo "[3/7] Pull latest code..." | |
| git reset --hard HEAD | |
| git pull origin main | |
| fi | |
| echo "[4/7] Set entrypoint.sh as executable" | |
| chmod +x $DEPLOY_DIR/entrypoint.sh | |
| echo "[5/7] Down all services..." | |
| docker compose down -v | |
| echo "[6/7] Remove image..." | |
| docker rmi "$CONTAINER_NAME-app" || true | |
| echo "[7/7] Up services..." | |
| docker-compose -p $CONTAINER_NAME up -d |