Skip to main content

Pacote utilizado para publicar mensagens MQTT quando um arquivo é atualizado.

Project description

update-trigger 🚀

PyPI version
License: MIT

Pacote Python utilizado para publicar mensagens MQTT (payload "update") quando acionado em pipelines de CI/CD, como no GitHub Actions.

Esse pacote facilita a integração com serviços que precisam ser notificados sobre atualizações de arquivos ou sistemas.


📦 Instalação

Instale o pacote via PyPI (após publicação):

pip install update-trigger

Ou localmente durante o desenvolvimento:

pip install .

⚙️ Configuração

O pacote utiliza variáveis de ambiente para se conectar ao broker MQTT.
Crie um arquivo .env com as seguintes chaves:

MQTT_BROKER=test.mosquitto.org
MQTT_PORT=8883
MQTT_USERNAME=seu_usuario
MQTT_PASSWORD=sua_senha

🧩 Uso em Python

Você pode importar a classe MqttService diretamente no seu projeto:

from update_trigger import MqttService
import os

service = MqttService(
    broker=os.environ["MQTT_BROKER"],
    port=int(os.environ["MQTT_PORT"]),
    client_id="github-actions",
    topic="actions",
)

service.send_message()

🤖 Uso no GitHub Actions

Exemplo de workflow que dispara o update-trigger após um push na branch main:

name: Trigger MQTT Update

on:
  push:
    branches:
      - main

jobs:
  mqtt-notify:
    runs-on: ubuntu-latest

    steps:
      - name: Checkout repository
        uses: actions/checkout@v4

      - name: Setup Python
        uses: actions/setup-python@v5
        with:
          python-version: "3.11"

      - name: Install update-trigger
        run: pip install update-trigger

      - name: Send MQTT update
        env:
          MQTT_BROKER: ${{ secrets.MQTT_BROKER }}
          MQTT_PORT: ${{ secrets.MQTT_PORT }}
          MQTT_USERNAME: ${{ secrets.MQTT_USERNAME }}
          MQTT_PASSWORD: ${{ secrets.MQTT_PASSWORD }}
        run: python -m update_trigger

⚠️ Configure os valores de conexão (MQTT_BROKER, MQTT_PORT, MQTT_USERNAME, MQTT_PASSWORD) como GitHub Secrets para maior segurança.


📜 Licença

Distribuído sob a licença MIT. Veja o arquivo LICENSE para mais detalhes.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

update_trigger-0.1.2.tar.gz (3.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

update_trigger-0.1.2-py3-none-any.whl (3.8 kB view details)

Uploaded Python 3

File details

Details for the file update_trigger-0.1.2.tar.gz.

File metadata

  • Download URL: update_trigger-0.1.2.tar.gz
  • Upload date:
  • Size: 3.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for update_trigger-0.1.2.tar.gz
Algorithm Hash digest
SHA256 ad7ab4c79355115a9589c63b851c6a9c19355a8fe818dbcf5d44ec39ffe354c7
MD5 b8a864d3abe332eff28b981090f4311e
BLAKE2b-256 13554b0d9c0d077c225ffe7ec9b497899bfbfa5aa5bc96fd42d598e2ad46b74e

See more details on using hashes here.

File details

Details for the file update_trigger-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: update_trigger-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 3.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for update_trigger-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 1ae41751933abd6215ed9ccf6c39ee040efe44feb3988fd717a58adcc5495bbb
MD5 89e9013bc5109c106e0d2b7f20c3d8d1
BLAKE2b-256 a460921157910ed40957abbc0721e962fcc259925c4148a08273f47dac8461ae

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page