Refactor docker-compose.yml to standardize service names #11
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: Deploy | |
| on: | |
| push: | |
| branches: | |
| - develop | |
| - main | |
| workflow_dispatch: | |
| jobs: | |
| test: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Install Python deps | |
| run: | | |
| sudo apt-get update | |
| sudo apt-get install -y python3-pip | |
| pip3 install --upgrade pip | |
| pip3 install --no-cache-dir -r solver-bot/requirements.txt | |
| - name: Run Python tests | |
| run: | | |
| # Run Python tests | |
| - name: Install Maven | |
| run: | | |
| sudo apt-get update && \ | |
| sudo apt-get install -y --no-install-recommends maven | |
| - name: Run Maven tests | |
| run: | | |
| # Run Maven tests | |
| build-and-push: | |
| needs: test | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Verify DockerHub credentials | |
| run: | | |
| if [ -z "${{ secrets.DOCKERHUB_USERNAME }}" ] || [ -z "${{ secrets.DOCKERHUB_PASSWORD }}" ]; then | |
| echo "Missing DockerHub credentials" | |
| exit 1 | |
| fi | |
| - name: Log in to Docker Hub | |
| if: github.ref == 'refs/heads/main' | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: docker.io | |
| username: ${{ secrets.DOCKERHUB_USERNAME }} | |
| password: ${{ secrets.DOCKERHUB_PASSWORD }} | |
| - name: Build and push diffy-bot-client | |
| if: github.ref == 'refs/heads/main' | |
| uses: docker/build-push-action@v4 | |
| with: | |
| context: . | |
| file: solver-bot/Dockerfile | |
| push: true | |
| tags: ${{ secrets.DOCKERHUB_USERNAME }}/diffy-bot-client:latest | |
| - name: Build and push diffy-bot-server | |
| if: github.ref == 'refs/heads/main' | |
| uses: docker/build-push-action@v4 | |
| with: | |
| context: . | |
| file: solver-common/Dockerfile | |
| push: true | |
| tags: ${{ secrets.DOCKERHUB_USERNAME }}/diffy-bot-server:latest | |
| deploy: | |
| needs: build-and-push | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Create .env file from secrets | |
| run: | | |
| echo "CLIENT_API_KEY=${{ secrets.CLIENT_API_KEY }}" >> .env | |
| echo "DB_CONNECTION=${{ secrets.DB_CONNECTION }}" >> .env | |
| echo "DB_PORT=${{ secrets.DB_PORT }}" >> .env | |
| echo "DB_DATABASE=${{ secrets.DB_DATABASE }}" >> .env | |
| echo "DB_USERNAME=${{ secrets.DB_USERNAME }}" >> .env | |
| echo "DB_PASSWORD=${{ secrets.DB_PASSWORD }}" >> .env | |
| - name: Run Docker Compose | |
| run: | | |
| docker compose -f docker-compose.yml pull || true | |
| docker compose -f docker-compose.yml up -d |