Add step Fix Prometheus data folder permissions for GitHub Actions #3
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: Docker Compose Test | |
| on: | |
| push: | |
| branches: [main] | |
| pull_request: {} | |
| workflow_dispatch: {} | |
| jobs: | |
| compose-test: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - name: Validate Docker Compose | |
| run: docker compose config | |
| - name: Validate Prometheus config | |
| run: | | |
| curl -sSL https://github.com/prometheus/prometheus/releases/download/v2.48.0/prometheus-2.48.0.linux-amd64.tar.gz | tar -xz | |
| ./prometheus-2.48.0.linux-amd64/promtool check config ./prometheus/config/prometheus.yml | |
| - name: Build services | |
| run: docker compose build | |
| - name: Start services | |
| run: docker compose up -d | |
| - name: Fix Prometheus data folder permissions | |
| run: sudo chown -R 65534:65534 ./prometheus/data | |
| - name: Wait for containers to initialize | |
| run: sleep 20 | |
| - name: Check containers are running | |
| run: | | |
| set -e | |
| services=("prometheus" "grafana" "nginx" "alertmanager") | |
| for svc in "${services[@]}"; do | |
| status=$(docker inspect -f '{{.State.Health.Status}}' "$svc" 2>/dev/null || echo "unknown") | |
| if [[ "$status" == "healthy" || "$status" == "starting" ]]; then | |
| echo "✅ $svc container is running ($status)" | |
| else | |
| echo "❌ $svc container not healthy" | |
| docker logs "$svc" || true | |
| exit 1 | |
| fi | |
| done | |
| - name: Stop services | |
| if: always() | |
| run: docker compose down |