Merge pull request #1 from heyvaldemar/dependabot/github_actions/acti… #10
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: Deployment Verification | |
| on: | |
| push: | |
| branches: | |
| - main | |
| pull_request: | |
| branches: | |
| - main | |
| jobs: | |
| deploy-and-test: | |
| runs-on: ubuntu-latest | |
| env: | |
| DOCKER_COMPOSE_FILE: minecraft-server-proxy-docker-compose.yml | |
| APP_HOSTNAME: minecraft-server-proxy.heyvaldemar.net | |
| COMPOSE_PROJECT_NAME: minecraft-server-proxy | |
| MINECRAFT_PORT: 25565 | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v5 | |
| - name: Start up services using Docker Compose | |
| run: docker compose -f $DOCKER_COMPOSE_FILE -p $COMPOSE_PROJECT_NAME up -d | |
| - name: Modify /etc/hosts for internal routing | |
| run: | | |
| echo "127.0.0.1 $APP_HOSTNAME" | sudo tee -a /etc/hosts | |
| - name: Print Docker Compose services status | |
| run: docker ps | |
| - name: Install Python and mcstatus | |
| run: | | |
| sudo apt-get update | |
| sudo apt-get install -y python3-pip | |
| pip3 install mcstatus | |
| - name: Wait for the Minecraft Server to be ready | |
| run: | | |
| echo "Checking Minecraft server readiness at $APP_HOSTNAME:$MINECRAFT_PORT..." | |
| timeout 5m bash -c 'while ! mcstatus $APP_HOSTNAME:$MINECRAFT_PORT status; do \ | |
| echo "Waiting for the Minecraft server to be ready..."; \ | |
| sleep 10; \ | |
| done' | |
| - name: Show container logs on failure | |
| if: failure() | |
| run: docker compose -f $DOCKER_COMPOSE_FILE -p $COMPOSE_PROJECT_NAME logs | |
| - name: Shutdown Docker Compose services | |
| if: always() | |
| run: docker compose -f $DOCKER_COMPOSE_FILE -p $COMPOSE_PROJECT_NAME down |