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.1.tar.gz (3.1 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.1-py3-none-any.whl (3.4 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: update_trigger-0.1.1.tar.gz
  • Upload date:
  • Size: 3.1 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.1.tar.gz
Algorithm Hash digest
SHA256 de4493f963d5a8d561177a1621130b1adc6ebd51151c27adc45307e3acb60980
MD5 7664929eb75a0c10b813fc00cf154d93
BLAKE2b-256 f8e6f3aaceb97f1888d0c8520fd867e68fcbae74a3e2ecce8d41a3050c22c609

See more details on using hashes here.

File details

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

File metadata

  • Download URL: update_trigger-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 3.4 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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 5ba9698ca2d35b50533fd769b93a438c88bf733b3b026b9ea4fa5d0c5eaf93c2
MD5 7e8ed68fa1db42f5883fa3723af68537
BLAKE2b-256 a24bffd74391b19fb491bd2d748d0d3c28f0ba36eccba87aebd5dd8684c1180f

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