GitHub Actions
The ConnectMQ MQTT Publish action sends an MQTT message from any GitHub workflow, for example "deployment finished" to a dashboard or a command to a device fleet.
Set up the secrets
In your repository, Settings → Secrets and variables → Actions → New repository secret:
| Secret | Value |
|---|---|
MQTT_USERNAME | Username from MQTT Connection Settings |
MQTT_PASSWORD | Password |
MQTT_CLIENT_ID | Issued client ID |
TIP
Create a dedicated credential set for CI with Add credentials, so you can revoke it without affecting devices.
Workflow
yaml
name: Notify devices
on:
push:
branches: [main]
jobs:
publish:
runs-on: ubuntu-latest
steps:
- uses: connectmq/connectmq-mqtt-publish@v1
with:
username: ${{ secrets.MQTT_USERNAME }}
password: ${{ secrets.MQTT_PASSWORD }}
client-id: ${{ secrets.MQTT_CLIENT_ID }}
topic: myproject/ci/deploy
message: '{"status":"deployed","sha":"${{ github.sha }}"}'Defaults
| Input | Default |
|---|---|
host | broker.connectmq.com |
protocol / port | mqtts / 8883 (also mqtt 1883, ws 8083, wss 8084) |
mqtt-version | 5 |
qos | 1 |
retain | false |
client-id-suffix | true: appends _gha-<run id>-<random> so parallel jobs never share a client ID |
Each run opens a short connection that counts towards your concurrent connections and session minutes. Full reference: action README.