diff --git a/.github/actions/ci.yml b/.github/actions/ci.yml new file mode 100644 index 0000000..4a140bd --- /dev/null +++ b/.github/actions/ci.yml @@ -0,0 +1,42 @@ +name: CI + +on: + push: + branches: + - main + pull_request: + branches: + - main + +jobs: + test-mosquitto: + runs-on: ubuntu-latest + + steps: + - name: Checkout repository + uses: actions/checkout@v2 + + - name: Set up Docker Compose + run: | + sudo apt-get update + sudo apt-get install -y docker-compose + + - name: Start Mosquitto service using Docker Compose + run: docker-compose up -d mosquitto + + - name: Wait for Mosquitto to be healthy + run: | + for i in {1..10}; do + if docker inspect --format='{{.State.Status}}' mosquitto | grep -q running; then + echo "Mosquitto is running" + exit 0 + else + echo "Waiting for Mosquitto to be healthy..." + sleep 10 + fi + done + echo "Mosquitto did not become healthy in time" + exit 1 + + - name: Stop Mosquitto service using Docker Compose + run: docker-compose down diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..4a140bd --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,42 @@ +name: CI + +on: + push: + branches: + - main + pull_request: + branches: + - main + +jobs: + test-mosquitto: + runs-on: ubuntu-latest + + steps: + - name: Checkout repository + uses: actions/checkout@v2 + + - name: Set up Docker Compose + run: | + sudo apt-get update + sudo apt-get install -y docker-compose + + - name: Start Mosquitto service using Docker Compose + run: docker-compose up -d mosquitto + + - name: Wait for Mosquitto to be healthy + run: | + for i in {1..10}; do + if docker inspect --format='{{.State.Status}}' mosquitto | grep -q running; then + echo "Mosquitto is running" + exit 0 + else + echo "Waiting for Mosquitto to be healthy..." + sleep 10 + fi + done + echo "Mosquitto did not become healthy in time" + exit 1 + + - name: Stop Mosquitto service using Docker Compose + run: docker-compose down diff --git a/README.md b/README.md index c7806f7..563b7fc 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,5 @@ +![CI](https://github.com/jzombie/docker-mqtt-mosquitto-cloudflare-tunnel/actions/workflows/ci.yml/badge.svg) + # Docker MQTT Mosquitto Cloudflare Tunnel This setup demonstrates how to configure and deploy an MQTT broker using Eclipse Mosquitto within a Docker container and securely expose it to the internet via a Cloudflare Tunnel. This setup is particularly useful for IoT applications, allowing secure and scalable message brokering over the MQTT protocol.