FIX fix #17
This file contains 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: MQTT Broker Example | |
#on: [push] | |
jobs: | |
mqtt: | |
runs-on: ubuntu-latest | |
services: | |
mosquitto: | |
image: eclipse-mosquitto:latest | |
ports: | |
- 1883:1883 | |
options: >- | |
--name mosquitto | |
env: | |
MOSQUITTO_USERNAME: user1 | |
MOSQUITTO_PASSWORD: pass1 | |
#volumes: | |
# - ./mosquitto.conf:/mosquitto/config/mosquitto.conf:ro | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v2 | |
- name: Install mosquitto clients | |
run: sudo apt-get update && sudo apt-get install -y mosquitto-clients | |
- name: Publish anonymously | |
run: mosquitto_pub -h localhost -p 1883 -t "test/topic" -m "Hello from anonymous" | |
- name: Publish with user1 | |
run: mosquitto_pub -h localhost -p 1883 -u user1 -P pass1 -t "test/topic" -m "Hello from user1" | |
- name: Verify messages | |
run: mosquitto_sub -h localhost -p 1883 -t "test/topic" -C 2 | |
# Create a mosquitto.conf file in the same directory with the following content: | |
# listener 1883 | |
# allow_anonymous true | |
# password_file /mosquitto/config/passwordfile | |
# Create a password file with the following command: | |
# mosquitto_passwd -c /mosquitto/config/passwordfile user1 |